问题描述
我的模型中有一个名为客户"的表,其中有一个字段"IsActive".每当我在客户"上运行查询时,都只应检索活动的客户.我可以在每个查询中都包含过滤器,但这看起来并不十分.我希望能够覆盖对象上下文"控制杆上的客户"属性,但是不确定是否可行.任何帮助将不胜感激!谢谢
I have a table in my model named Customers with a field IsActive. Whenever I run a query on Customers, only the active customers should be retrieved. I can include the filter in every query, but that doesn't look very. I would like to be able to override the Customers property at the Object Context lever, but I am not sure if this is possible. Any help would be very appreciated! Thanks
推荐答案
尽管回复较晚,但我会将其放在此处,以便为他人提供帮助.
Although a late response, I will put it here so it can help others.
您还可以在edmx文件中为您的实体设置条件.选择您的实体和转到映射详细信息",然后创建一个新条件.
You can also set a condition for your entity in your edmx file. Select your entity and Goto Mapping Details and create a new condition.
这篇关于如何在实体框架上应用全局过滤器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!