1
我使用IDbCommandTreeInterceptor
来处理软删除功能,并且当我必须读取所有删除的实体时,我遇到了一些情况。为此,我想分开“只读”DbContext
,并希望我的拦截器不处理来自DbContext
的查询。有没有可能为确切的dbContext添加拦截器或从拦截器处理它如何?IDbCommandTreeInterceptor精确DbContext
我使用IDbCommandTreeInterceptor
来处理软删除功能,并且当我必须读取所有删除的实体时,我遇到了一些情况。为此,我想分开“只读”DbContext
,并希望我的拦截器不处理来自DbContext
的查询。有没有可能为确切的dbContext添加拦截器或从拦截器处理它如何?IDbCommandTreeInterceptor精确DbContext
假设你的特殊语境是类型的DontInterceptContext
您可以使用interceptionContext,就像这样:
public void TreeCreated(DbCommandTreeInterceptionContext interceptionContext)
{
...
if (interceptionContext.DbContexts.OfType<DontInterceptContext>().Any())
return;
检查在Any()
一个属性的值也是一个选择