我在EF6中创建了一个查询拦截器:
public class QueryCommandInterceptor : IDbCommandInterceptor
{
private readonly Stopwatch _stopWatch = new Stopwatch();
public void NonQueryExecuting(DbCommand command, DbCommandInterceptionContext<int> interceptionContext)
{
_stopWatch.Restart();
}
public void NonQueryExecuted(DbCommand command, DbCommandInterceptionContext<int> interceptionContext)
{
_stopWatch.Stop();
}
}
两个Executing方法可以在相应的Executed方法完成之前启动吗?
答案 0 :(得分:0)
你的意思是,这个IDbCommandInterceptor
线程安全吗?
Is IDbCommandInterceptor in EntityFramework 6 thread safe
答案是否定的。