I working on a C# win-form app.
in my form i have Data-Grid-View that bind with a Binding-Source and Binding-Source Data-source is a table of entity-framework.
when i use entity framework i cant use filter of the binding-source and the sort by columns of data-grid-view but when i don’t use entity framework i can use them.
how can i use them with entity-framework?
my code when form loads is
contex = new myEntity();
myBindingSource.DataSource = contex.myTable;
Every BindingSource has a property SupportsFiltering (and SupportsSorting). In case you set an entitySet as DataSource these two properties are automatically set to false! So there are some possible solutions. Either you provide an extension method to your
IEnumberable<T>as shown here or you choose to filter/sort usingLinq2Entities.Snippet for Linq2Entities could be:
Snippet for extension method:
Furthermore this subject has been discussed many times before, even here on SO.