IDbCommandInterceptor InterceptorInterceptorContext.SuppressExecution()不禁止查询

时间:2018-11-01 16:06:20

标签: c# entity-framework entity-framework-6

因此,我正在尝试使用interceptionContext.SuppressExecution()来防止在某些情况下将更新写入数据库。尽管设置了结果并调用了SuppressExecution()。更新命令仍将执行。

public class ExampleInterceptor : IDbCommandInterceptor
{

    public void NonQueryExecuting(DbCommand command, DbCommandInterceptionContext<int> interceptionContext)
    {
        interceptionContext.SuppressExecution();
        interceptionContext.Result = 1;
    }

    // Omitted the entire implementation
}

0 个答案:

没有答案