因此,我正在尝试使用interceptionContext.SuppressExecution()来防止在某些情况下将更新写入数据库。尽管设置了结果并调用了SuppressExecution()。更新命令仍将执行。
public class ExampleInterceptor : IDbCommandInterceptor
{
public void NonQueryExecuting(DbCommand command, DbCommandInterceptionContext<int> interceptionContext)
{
interceptionContext.SuppressExecution();
interceptionContext.Result = 1;
}
// Omitted the entire implementation
}