Class CommandInterceptor
- Namespace
- LinqToDB.Interceptors
- Assembly
- linq2db.dll
public abstract class CommandInterceptor : ICommandInterceptor, IInterceptor
- Inheritance
-
CommandInterceptor
- Implements
- Extension Methods
Methods
AfterExecuteReader(CommandEventData, DbCommand, CommandBehavior, DbDataReader)
Event, triggered after command execution using ExecuteReader(CommandBehavior) or ExecuteReaderAsync(CommandBehavior, CancellationToken) methods.
public virtual void AfterExecuteReader(CommandEventData eventData, DbCommand command, CommandBehavior commandBehavior, DbDataReader dataReader)
Parameters
eventDataCommandEventDataAdditional data for event.
commandDbCommandExecuted command.
commandBehaviorCommandBehaviorBehavior, used for command execution.
dataReaderDbDataReaderDbDataReader instance, returned by ExecuteReader(CommandBehavior) or ExecuteReaderAsync(CommandBehavior, CancellationToken) methods.
BeforeReaderDispose(CommandEventData, DbCommand?, DbDataReader)
Event, triggered after all data is consumed from DbDataReader before Dispose() call.
public virtual void BeforeReaderDispose(CommandEventData eventData, DbCommand? command, DbDataReader dataReader)
Parameters
eventDataCommandEventDataAdditional data for event.
commandDbCommandExecuted command. Could be
null.dataReaderDbDataReaderDbDataReader instance.
BeforeReaderDisposeAsync(CommandEventData, DbCommand?, DbDataReader)
Event, triggered after all data is consumed from DbDataReader before DisposeAsync call.
public virtual Task BeforeReaderDisposeAsync(CommandEventData eventData, DbCommand? command, DbDataReader dataReader)
Parameters
eventDataCommandEventDataAdditional data for event.
commandDbCommandExecuted command. Could be
null.dataReaderDbDataReaderDbDataReader instance.
Returns
CommandInitialized(CommandEventData, DbCommand)
Event, triggered after command prepared for execution with both command text and parameters set.
public virtual DbCommand CommandInitialized(CommandEventData eventData, DbCommand command)
Parameters
eventDataCommandEventDataAdditional data for event.
commandDbCommandInitialized command instance.
Returns
- DbCommand
Returns command instance for execution.
ExecuteNonQuery(CommandEventData, DbCommand, Option<int>)
Event, triggered before command execution using ExecuteNonQuery() method.
public virtual Option<int> ExecuteNonQuery(CommandEventData eventData, DbCommand command, Option<int> result)
Parameters
eventDataCommandEventDataAdditional data for event.
commandDbCommandCommand, prepared for execution.
resultOption<int>Value, returned by previous interceptor when multiple ICommandInterceptor instances registered or None.
Returns
- Option<int>
When event returns None, Linq To DB will execute command, otherwise it will use returned value as execution result.
ExecuteNonQueryAsync(CommandEventData, DbCommand, Option<int>, CancellationToken)
Event, triggered before command execution using ExecuteNonQueryAsync(CancellationToken) method.
public virtual Task<Option<int>> ExecuteNonQueryAsync(CommandEventData eventData, DbCommand command, Option<int> result, CancellationToken cancellationToken)
Parameters
eventDataCommandEventDataAdditional data for event.
commandDbCommandCommand, prepared for execution.
resultOption<int>Value, returned by previous interceptor when multiple ICommandInterceptor instances registered or None.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<Option<int>>
When event returns None, Linq To DB will execute command, otherwise it will use returned value as execution result.
ExecuteReader(CommandEventData, DbCommand, CommandBehavior, Option<DbDataReader>)
Event, triggered before command execution using ExecuteReader(CommandBehavior) method.
public virtual Option<DbDataReader> ExecuteReader(CommandEventData eventData, DbCommand command, CommandBehavior commandBehavior, Option<DbDataReader> result)
Parameters
eventDataCommandEventDataAdditional data for event.
commandDbCommandCommand, prepared for execution.
commandBehaviorCommandBehaviorBehavior, used for command execution.
resultOption<DbDataReader>Value, returned by previous interceptor when multiple ICommandInterceptor instances registered or None.
Returns
- Option<DbDataReader>
When event returns None, Linq To DB will execute command, otherwise it will use returned value as execution result.
ExecuteReaderAsync(CommandEventData, DbCommand, CommandBehavior, Option<DbDataReader>, CancellationToken)
Event, triggered before command execution using ExecuteReaderAsync(CommandBehavior, CancellationToken) method.
public virtual Task<Option<DbDataReader>> ExecuteReaderAsync(CommandEventData eventData, DbCommand command, CommandBehavior commandBehavior, Option<DbDataReader> result, CancellationToken cancellationToken)
Parameters
eventDataCommandEventDataAdditional data for event.
commandDbCommandCommand, prepared for execution.
commandBehaviorCommandBehaviorBehavior, used for command execution.
resultOption<DbDataReader>Value, returned by previous interceptor when multiple ICommandInterceptor instances registered or None.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<Option<DbDataReader>>
When event returns None, Linq To DB will execute command, otherwise it will use returned value as execution result.
ExecuteScalar(CommandEventData, DbCommand, Option<object?>)
Event, triggered before command execution using ExecuteScalar() method.
public virtual Option<object?> ExecuteScalar(CommandEventData eventData, DbCommand command, Option<object?> result)
Parameters
eventDataCommandEventDataAdditional data for event.
commandDbCommandCommand, prepared for execution.
resultOption<object>Value, returned by previous interceptor when multiple ICommandInterceptor instances registered or None.
Returns
- Option<object>
When event returns None, Linq To DB will execute command, otherwise it will use returned value as execution result.
ExecuteScalarAsync(CommandEventData, DbCommand, Option<object?>, CancellationToken)
Event, triggered before command execution using ExecuteScalarAsync(CancellationToken) method.
public virtual Task<Option<object?>> ExecuteScalarAsync(CommandEventData eventData, DbCommand command, Option<object?> result, CancellationToken cancellationToken)
Parameters
eventDataCommandEventDataAdditional data for event.
commandDbCommandCommand, prepared for execution.
resultOption<object>Value, returned by previous interceptor when multiple ICommandInterceptor instances registered or None.
cancellationTokenCancellationTokenCancellation token.