DbCommandInterceptionContext<TResult>.Exception 属性

定义

如果在执行操作之前设置了此属性,则会禁止执行该操作,并改为引发设置异常。 否则,如果操作失败,则此属性将设置为引发的异常。 在任一情况下,在操作后运行的侦听器都可以更改此属性以更改将引发的异常,或者将此属性设置为 null,以不引发任何异常。

public Exception Exception { get; set; }
member this.Exception : Exception with get, set
Public Property Exception As Exception

属性值

注解

当操作失败时, OriginalException 此属性和 属性都设置为引发的异常。 但是,此属性可由侦听器设置或更改,而 OriginalException 属性将始终表示引发的原始异常。

适用于