title: Data Binding of Computed Properties in Entity Framework
body: <p>I am trying to find an effective way to databind computed fields of an Entity Framework model in winforms.  I am using Visual Studio 2008 and .NET framework 3.5.  An example would be for EntityX, say I have columnA and columnB, and I want a computed property named sumAB.  The way I have been doing this has been with partial classes:</p>
  
  <pre><code>public partial class EntityX 
  {
      public int sumAB 
      {
          get 
          {
              return this.columnA + this.columnB;
          }
      }
  }
  </code></pre>
  
  <p>I then am using visual studio to add EntityX as a data source, so I can use the automatic drag and drop data binding.  The issue that I am having is that the computed properties are not appearing under the Data Source fields.  I am looking for a way to have the automatic databinding of computed fields.  </p>
  
  <p>I know I could do this manually, but then I would have to also manually write all of the binding code to refresh the field when columnA or columnB are changed.  I also do not have access to make this field computed on the SQL server side either.</p>
  
  <p>Does anyone know of any ways to accomplish this or any other similar directions to persue?</p>
  
  <p>Thanks!</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I tested this on another machine, using Visual Studio 2010 and .NET 4, and I am still receiving the same behavior.  Interestingly, I can manually create a textbox and add a databinding, and it will work fine, as below:</p>
  
  <pre><code>sumABTextBox.DataBindings.Add(
    new System.Windows.Forms.Binding("Text", EntityXBindingSource, "sumAB", true));
  </code></pre>
  
  <p>It also worked if I placed the property in the .edmx file, but this is not desirable, as it will be wiped any time the database is updated.</p>
  
  <p>Any other ideas?</p>
  
  <p><strong>UPDATE 2</strong></p>
  
  <p>Still no solution... I had to use alternatives in my code to meet deadlines.  I am still very interested in this if anyone finds an answer...</p>