IDbCommandInterceptor Interface

Definition

Allows interception of commands sent to a relational database.

public interface IDbCommandInterceptor : Microsoft.EntityFrameworkCore.Diagnostics.IInterceptor
type IDbCommandInterceptor = interface
    interface IInterceptor
Public Interface IDbCommandInterceptor
Implements IInterceptor
Derived
Implements

Remarks

Command interceptors can be used to view, change, or suppress execution of the DbCommand, and to modify the result before it is returned to EF.

Consider inheriting from DbCommandInterceptor if not implementing all methods.

Use AddInterceptors(IInterceptor[]) to register application interceptors.

Extensions can also register interceptors in the internal service provider. If both injected and application interceptors are found, then the injected interceptors are run in the order that they are resolved from the service provider, and then the application interceptors are run last.

See EF Core interceptors for more information and examples.

Methods

CommandCanceled(DbCommand, CommandEndEventData)

Called when a command was canceled.

CommandCanceledAsync(DbCommand, CommandEndEventData, CancellationToken)

Called when a command was canceled.

CommandCreated(CommandEndEventData, DbCommand)

Called immediately after EF calls CreateCommand().

CommandCreating(CommandCorrelatedEventData, InterceptionResult<DbCommand>)

Called just before EF intends to call CreateCommand().

CommandFailed(DbCommand, CommandErrorEventData)

Called when execution of a command has failed with an exception.

CommandFailedAsync(DbCommand, CommandErrorEventData, CancellationToken)

Called when execution of a command has failed with an exception.

CommandInitialized(CommandEndEventData, DbCommand)

Called after EF has initialized CommandText and other command configuration.

DataReaderClosing(DbCommand, DataReaderClosingEventData, InterceptionResult)

Called just before EF intends to call Close().

DataReaderClosingAsync(DbCommand, DataReaderClosingEventData, InterceptionResult)

Called just before EF intends to call CloseAsync() in an async context.

DataReaderDisposing(DbCommand, DataReaderDisposingEventData, InterceptionResult)

Called when execution of a DbDataReader is about to be disposed.

NonQueryExecuted(DbCommand, CommandExecutedEventData, Int32)

Called immediately after EF calls ExecuteNonQuery().

NonQueryExecutedAsync(DbCommand, CommandExecutedEventData, Int32, CancellationToken)

Called immediately after EF calls ExecuteNonQueryAsync().

NonQueryExecuting(DbCommand, CommandEventData, InterceptionResult<Int32>)

Called just before EF intends to call ExecuteNonQuery().

NonQueryExecutingAsync(DbCommand, CommandEventData, InterceptionResult<Int32>, CancellationToken)

Called just before EF intends to call ExecuteNonQueryAsync().

ReaderExecuted(DbCommand, CommandExecutedEventData, DbDataReader)

Called immediately after EF calls ExecuteReader().

ReaderExecutedAsync(DbCommand, CommandExecutedEventData, DbDataReader, CancellationToken)

Called immediately after EF calls ExecuteReaderAsync().

ReaderExecuting(DbCommand, CommandEventData, InterceptionResult<DbDataReader>)

Called just before EF intends to call ExecuteReader().

ReaderExecutingAsync(DbCommand, CommandEventData, InterceptionResult<DbDataReader>, CancellationToken)

Called just before EF intends to call ExecuteReaderAsync().

ScalarExecuted(DbCommand, CommandExecutedEventData, Object)

Called immediately after EF calls ExecuteScalar().

ScalarExecutedAsync(DbCommand, CommandExecutedEventData, Object, CancellationToken)

Called immediately after EF calls ExecuteScalarAsync().

ScalarExecuting(DbCommand, CommandEventData, InterceptionResult<Object>)

Called just before EF intends to call ExecuteScalar().

ScalarExecutingAsync(DbCommand, CommandEventData, InterceptionResult<Object>, CancellationToken)

Called just before EF intends to call ExecuteScalarAsync().

Applies to