本文介绍了EntityFramework4.1的.Local()。ToBindingList(),如何过滤呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

示例模型:客户 - >订单

Example Model: Customer -> Order

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

然后,如何过滤?例如 context.Order.Where(m => m.customerID> 1)

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

我想得到BindingList实现与Local属性返回的ObservableCollection保持同步。

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

推荐答案

您是否尝试使用选择?

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

修改

不完全确定,它编译,但我没有一个完整的环境来测试它。也许如果您尝试加载特定的数据,然后您可以在本地访问绑定列表。像这样:

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

这篇关于EntityFramework4.1的.Local()。ToBindingList(),如何过滤呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 21:50