Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EntityFramework4.1's .Local().ToBindingList() , How to filter then?

Example Model: Customer -> Order

contex.Order.Load();
orderBindingSource.DataSource = context.Order.Local().ToBindingList();

Then, how to filter? e.g. context.Order.Where(m=>m.customerID > 1)

I want to get the BindingList implementation that stays in sync with the ObservableCollection returned by the Local property.

like image 266
John Smith Avatar asked Sep 22 '11 18:09

John Smith


1 Answers

Have you tried using select?

contex.Order.Load();
orderBindingSource.DataSource = 
   context.Order.Local().Select( m => m.customerID > 1).ToBindingList();

Edit

Not entirely sure about this, it compiles but I do not have a full environment to test it. Perhaps if you try to load in the specific data, and then you can access it in local for the binding list. Like this:

context.Order.Select( m => m.customerID > 1).Load();
orderBindingSource.DataSource = 
   context.Order.Local.ToBindingList();
like image 185
Travis J Avatar answered Sep 19 '22 22:09

Travis J