DbCommandTreeInterceptionContext
和DbCommandInterceptionContext
都包含UserState
属性,但不会从一个属性转移到另一个属性。 I.E.在这种情况下:
public class DummyDbCommandTreeInterceptor : IDbCommandTreeInterceptor
{
public void TreeCreated(DbCommandTreeInterceptionContext interceptionContext)
{
interceptionContext.UserState = "test";
}
}
public class DummyDbCommandInterceptor : DbCommandInterceptor
{
public override void ReaderExecuting(DbCommand command,
DbCommandInterceptionContext<DbDataReader> interceptionContext)
{
if (interceptionContext.UserState != "test")
{
throw new Exception("wtf");
}
}
}
将抛出异常。有没有办法在两者之间分享状态?