/// <summary> /// Called just before EF intends to call <see cref="DbConnection.OpenAsync()" />. /// </summary> /// <param name="connection"> The connection. </param> /// <param name="eventData"> Contextual information about the connection. </param> /// <param name="result"> /// Represents the current result if one exists. /// This value will have <see cref="InterceptionResult.IsSuppressed"/> set to true if some previous /// interceptor suppressed execution by calling <see cref="InterceptionResult.Suppress"/>. /// This value is typically used as the return value for the implementation of this method. /// </param> /// <param name="cancellationToken"> The cancellation token. </param> /// <returns> /// If <see cref="InterceptionResult.IsSuppressed"/> is false, the EF will continue as normal. /// If <see cref="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 <paramref name="result" /> value passed in. /// </returns> public virtual Task <InterceptionResult> ConnectionOpeningAsync( DbConnection connection, ConnectionEventData eventData, InterceptionResult result, CancellationToken cancellationToken = default) => Task.FromResult(result);
/// <summary> /// Called just before EF intends to call <see cref="DbConnection.CloseAsync()" /> in an async context. /// </summary> /// <param name="connection"> The connection. </param> /// <param name="eventData"> Contextual information about the connection. </param> /// <param name="result"> /// Represents the current result if one exists. /// This value will have <see cref="InterceptionResult.IsSuppressed"/> set to true if some previous /// interceptor suppressed execution by calling <see cref="InterceptionResult.Suppress"/>. /// This value is typically used as the return value for the implementation of this method. /// </param> /// <returns> /// If <see cref="InterceptionResult.IsSuppressed"/> is false, the EF will continue as normal. /// If <see cref="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 <paramref name="result" /> value passed in. /// </returns> public virtual Task <InterceptionResult> ConnectionClosingAsync( DbConnection connection, ConnectionEventData eventData, InterceptionResult result) => Task.FromResult(result);
/// <summary> /// Called just before EF intends to call <see cref="DbConnection.Open()" />. /// </summary> /// <param name="connection"> The connection. </param> /// <param name="eventData"> Contextual information about the connection. </param> /// <param name="result"> /// Represents the current result if one exists. /// This value will have <see cref="InterceptionResult.IsSuppressed"/> set to true if some previous /// interceptor suppressed execution by calling <see cref="InterceptionResult.Suppress"/>. /// This value is typically used as the return value for the implementation of this method. /// </param> /// <returns> /// If <see cref="InterceptionResult.IsSuppressed"/> is false, the EF will continue as normal. /// If <see cref="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 <paramref name="result" /> value passed in. /// </returns> public virtual InterceptionResult ConnectionOpening( DbConnection connection, ConnectionEventData eventData, InterceptionResult result) => result;
/// <summary> /// Called just before EF intends to call <see cref="DbConnection.CloseAsync()" /> in an async context. /// </summary> /// <param name="connection"> The connection. </param> /// <param name="eventData"> Contextual information about the connection. </param> /// <param name="result"> /// Represents the current result if one exists. /// This value will have <see cref="InterceptionResult.IsSuppressed" /> set to <see langword="true" /> if some previous /// interceptor suppressed execution by calling <see cref="InterceptionResult.Suppress" />. /// This value is typically used as the return value for the implementation of this method. /// </param> /// <returns> /// If <see cref="InterceptionResult.IsSuppressed" /> is false, the EF will continue as normal. /// If <see cref="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 <paramref name="result" /> value passed in. /// </returns> public virtual ValueTask <InterceptionResult> ConnectionClosingAsync( DbConnection connection, ConnectionEventData eventData, InterceptionResult result) => new ValueTask <InterceptionResult>(result);