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

眉间皱痕 提交于 2019-12-06 20:16:18

问题


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.


回答1:


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();


来源:https://stackoverflow.com/questions/7519315/entityframework4-1s-local-tobindinglist-how-to-filter-then

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!