问题
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