如何为所有上下文获取查询添加特定条件? [英] How do add a specific condition to all context get queries?

查看:64
本文介绍了如何为所有上下文获取查询添加特定条件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello亲爱的,



我的情况如下:

我想改变我的应用程序中的所有获取查询以跳过删除在DB中标记为已删除的记录。



我可以将上下文配置为排除而不是更改所有查询吗?



问候,

Amr



我尝试过:



i搜索了很多,但我没有得到任何结果。

我也尝试编辑所有获取查询但这将需要大量的时间。

解决方案

引用:

我可以配置要排除的上下文吗而不是改变所有查询?



不,你必须改变你的查询。



详情请见:

实体框架使用DbContext [ ^ ]

实体框架查询和查找实体 [ ^ ]


Hello dears,

I have a situation as follows:
I want to alter all get queries in my application to skip deleted records which is marked as deleted in DB.

Can i configure the context to exclude to do that instead of altering all queries?

Regards,
Amr

What I have tried:

i have searched a lot but i didn't get any result.
I 've also tried to edit all get queries but this will take a lot of time.

解决方案

Quote:

Can i configure the context to exclude to do that instead of altering all queries?


No, you have to alter your queries.

For further details, please see:
Entity Framework Working with DbContext[^]
Entity Framework Querying and Finding Entities[^]


这篇关于如何为所有上下文获取查询添加特定条件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆