Class DbConnectionInterceptor
- Namespace
- Microsoft.EntityFrameworkCore.Diagnostics
- Assembly
- Microsoft.EntityFrameworkCore.Relational.dll
Abstract base class for IDbConnectionInterceptor for use when implementing a subset of the interface methods.
public abstract class DbConnectionInterceptor : IDbConnectionInterceptor, IInterceptor
- Inheritance
-
DbConnectionInterceptor
- Implements
-
IInterceptor
- Inherited Members
Constructors
DbConnectionInterceptor()
protected DbConnectionInterceptor()
Methods
ConnectionClosed(DbConnection, ConnectionEndEventData)
Called just after EF has called Close() in an async context.
public virtual void ConnectionClosed(DbConnection connection, ConnectionEndEventData eventData)
Parameters
connection
DbConnectionThe connection.
eventData
ConnectionEndEventDataContextual information about the connection.
ConnectionClosedAsync(DbConnection, ConnectionEndEventData)
Called just after EF has called CloseAsync().
public virtual Task ConnectionClosedAsync(DbConnection connection, ConnectionEndEventData eventData)
Parameters
connection
DbConnectionThe connection.
eventData
ConnectionEndEventDataContextual information about the connection.
Returns
ConnectionClosing(DbConnection, ConnectionEventData, InterceptionResult)
Called just before EF intends to call Close().
public virtual InterceptionResult ConnectionClosing(DbConnection connection, ConnectionEventData eventData, InterceptionResult result)
Parameters
connection
DbConnectionThe connection.
eventData
ConnectionEventDataContextual information about the connection.
result
InterceptionResultRepresents the current result if one exists. This value will have Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult.IsSuppressed set to true if some previous interceptor suppressed execution by calling Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult.Suppress. This value is typically used as the return value for the implementation of this method.
Returns
- InterceptionResult
If Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult.IsSuppressed is false, the EF will continue as normal. If Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult.IsSuppressed is true, then EF will suppress the operation it was about to perform. A normal implementation of this method for any interceptor that is not attempting to suppress the operation is to return the
result
value passed in.
ConnectionClosingAsync(DbConnection, ConnectionEventData, InterceptionResult)
Called just before EF intends to call CloseAsync() in an async context.
public virtual ValueTask<InterceptionResult> ConnectionClosingAsync(DbConnection connection, ConnectionEventData eventData, InterceptionResult result)
Parameters
connection
DbConnectionThe connection.
eventData
ConnectionEventDataContextual information about the connection.
result
InterceptionResultRepresents the current result if one exists. This value will have Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult.IsSuppressed set to true if some previous interceptor suppressed execution by calling Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult.Suppress. This value is typically used as the return value for the implementation of this method.
Returns
- ValueTask<InterceptionResult>
If Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult.IsSuppressed is false, the EF will continue as normal. If Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult.IsSuppressed is true, then EF will suppress the operation it was about to perform. A normal implementation of this method for any interceptor that is not attempting to suppress the operation is to return the
result
value passed in.
ConnectionFailed(DbConnection, ConnectionErrorEventData)
Called when opening of a connection has failed with an exception.
public virtual void ConnectionFailed(DbConnection connection, ConnectionErrorEventData eventData)
Parameters
connection
DbConnectionThe connection.
eventData
ConnectionErrorEventDataContextual information about the connection.
ConnectionFailedAsync(DbConnection, ConnectionErrorEventData, CancellationToken)
Called when opening of a connection has failed with an exception.
public virtual Task ConnectionFailedAsync(DbConnection connection, ConnectionErrorEventData eventData, CancellationToken cancellationToken = default)
Parameters
connection
DbConnectionThe connection.
eventData
ConnectionErrorEventDataContextual information about the connection.
cancellationToken
CancellationTokenThe cancellation token.
Returns
ConnectionOpened(DbConnection, ConnectionEndEventData)
Called just after EF has called Open().
public virtual void ConnectionOpened(DbConnection connection, ConnectionEndEventData eventData)
Parameters
connection
DbConnectionThe connection.
eventData
ConnectionEndEventDataContextual information about the connection.
ConnectionOpenedAsync(DbConnection, ConnectionEndEventData, CancellationToken)
Called just after EF has called OpenAsync().
public virtual Task ConnectionOpenedAsync(DbConnection connection, ConnectionEndEventData eventData, CancellationToken cancellationToken = default)
Parameters
connection
DbConnectionThe connection.
eventData
ConnectionEndEventDataContextual information about the connection.
cancellationToken
CancellationTokenThe cancellation token.
Returns
ConnectionOpening(DbConnection, ConnectionEventData, InterceptionResult)
Called just before EF intends to call Open().
public virtual InterceptionResult ConnectionOpening(DbConnection connection, ConnectionEventData eventData, InterceptionResult result)
Parameters
connection
DbConnectionThe connection.
eventData
ConnectionEventDataContextual information about the connection.
result
InterceptionResultRepresents the current result if one exists. This value will have Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult.IsSuppressed set to true if some previous interceptor suppressed execution by calling Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult.Suppress. This value is typically used as the return value for the implementation of this method.
Returns
- InterceptionResult
If Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult.IsSuppressed is false, the EF will continue as normal. If Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult.IsSuppressed is true, then EF will suppress the operation it was about to perform. A normal implementation of this method for any interceptor that is not attempting to suppress the operation is to return the
result
value passed in.
ConnectionOpeningAsync(DbConnection, ConnectionEventData, InterceptionResult, CancellationToken)
Called just before EF intends to call OpenAsync().
public virtual ValueTask<InterceptionResult> ConnectionOpeningAsync(DbConnection connection, ConnectionEventData eventData, InterceptionResult result, CancellationToken cancellationToken = default)
Parameters
connection
DbConnectionThe connection.
eventData
ConnectionEventDataContextual information about the connection.
result
InterceptionResultRepresents the current result if one exists. This value will have Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult.IsSuppressed set to true if some previous interceptor suppressed execution by calling Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult.Suppress. This value is typically used as the return value for the implementation of this method.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- ValueTask<InterceptionResult>
If Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult.IsSuppressed is false, the EF will continue as normal. If Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult.IsSuppressed is true, then EF will suppress the operation it was about to perform. A normal implementation of this method for any interceptor that is not attempting to suppress the operation is to return the
result
value passed in.