Struct InterceptionResult<TResult>
- Namespace
- Microsoft.EntityFrameworkCore.Diagnostics
- Assembly
- Microsoft.EntityFrameworkCore.dll
Represents a result from an IInterceptor such as an ISaveChangesInterceptor to allow suppression of the normal operation being intercepted.
public readonly struct InterceptionResult<TResult>
Type Parameters
TResult
The new result to use.
- Inherited Members
Remarks
A value of this type is passed to all interceptor methods that are called before the operation being intercepted is executed. Typically the interceptor should return the value passed in. However, creating a result with SuppressWithResult(TResult) causes the operation being intercepted to be suppressed; that is, the operation is not executed. The value in the result is then used as a substitute return value for the operation that was suppressed.
See EF Core interceptors for more information and examples.
Properties
HasResult
If true, then interception is suppressed, and Result contains the result to use.
public bool HasResult { get; }
Property Value
Result
The result to use.
public TResult Result { get; }
Property Value
- TResult
Remarks
The property can only be accessed if HasResult is true. The concept here is the same as Value and HasValue
Exceptions
Methods
SuppressWithResult(TResult)
Creates a new InterceptionResult<TResult> instance indicating that execution should be suppressed and the given result should be used instead.
public static InterceptionResult<TResult> SuppressWithResult(TResult result)
Parameters
result
TResultThe result to use.
Returns
- InterceptionResult<TResult>