/// <summary> /// Called just before EF intends to call <see cref="DbCommand.ExecuteNonQuery()" />. /// </summary> /// <param name="command"> The command. </param> /// <param name="eventData"> Contextual information about the command and execution. </param> /// <param name="result"> /// The current result, or null if no result yet exists. /// This value will be non-null if some previous interceptor suppressed execution by returning a result from /// its implementation of this method. /// This value is typically used as the return value for the implementation of this method. /// </param> /// <returns> /// If null, then EF will execute the command as normal. /// If non-null, then command execution is suppressed and the value contained in /// the <see cref="InterceptionResult{TResult}" /> we be used by EF instead. /// A normal implementation of this method for any interceptor that is not attempting to change the result /// is to return the <paramref name="result" /> value passed in. /// </returns> public virtual InterceptionResult <int>?NonQueryExecuting( DbCommand command, CommandEventData eventData, InterceptionResult <int>?result) => result;
/// <summary> /// Called just before EF intends to call <see cref="DbCommand.ExecuteScalar()" />. /// </summary> /// <param name="command"> The command. </param> /// <param name="eventData"> Contextual information about the command and execution. </param> /// <param name="result"> /// The current result, or null if no result yet exists. /// This value will be non-null if some previous interceptor suppressed execution by returning a result from /// its implementation of this method. /// This value is typically used as the return value for the implementation of this method. /// </param> /// <returns> /// If null, then EF will execute the command as normal. /// If non-null, then command execution is suppressed and the value contained in /// the <see cref="InterceptionResult{TResult}" /> we be used by EF instead. /// A normal implementation of this method for any interceptor that is not attempting to change the result /// is to return the <paramref name="result" /> value passed in. /// </returns> public virtual InterceptionResult <object>?ScalarExecuting( DbCommand command, CommandEventData eventData, InterceptionResult <object>?result) => result;
/// <summary> /// Called just before EF intends to call <see cref="DbCommand.ExecuteNonQueryAsync()" />. /// </summary> /// <param name="command"> The command. </param> /// <param name="eventData"> Contextual information about the command and execution. </param> /// <param name="result"> /// The current result, or null if no result yet exists. /// This value will be non-null if some previous interceptor suppressed execution by returning a result from /// its implementation of this method. /// 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 the <see cref="Task" /> result is null, then EF will execute the command as normal. /// If the <see cref="Task" /> result is non-null value, then command execution is suppressed and the value contained in /// the <see cref="InterceptionResult{TResult}" /> we be used by EF instead. /// A normal implementation of this method for any interceptor that is not attempting to change the result /// is to return the <paramref name="result" /> value passed in, often using <see cref="Task.FromResult{TResult}" /> /// </returns> public virtual Task <InterceptionResult <int>?> NonQueryExecutingAsync( DbCommand command, CommandEventData eventData, InterceptionResult <int>?result, CancellationToken cancellationToken = default) => Task.FromResult(result);
/// <summary> /// Called just before EF intends to call <see cref="DbCommand.ExecuteReader()" />. /// </summary> /// <param name="command"> The command. </param> /// <param name="eventData"> Contextual information about the command and execution. </param> /// <param name="result"> /// Represents the current result if one exists. /// This value will have <see cref="InterceptionResult{DbDataReader}.HasResult" /> set to true if some previous /// interceptor suppressed execution by calling <see cref="InterceptionResult{DbDataReader}.SuppressWithResult" />. /// This value is typically used as the return value for the implementation of this method. /// </param> /// <returns> /// If <see cref="InterceptionResult{DbDataReader}.HasResult" /> is false, the EF will continue as normal. /// If <see cref="InterceptionResult{DbDataReader}.HasResult" /> is true, then EF will suppress the operation it /// was about to perform and use <see cref="InterceptionResult{DbDataReader}.Result" /> instead. /// A normal implementation of this method for any interceptor that is not attempting to change the result /// is to return the <paramref name="result" /> value passed in, often using <see cref="Task.FromResult{TResult}" /> /// </returns> public virtual InterceptionResult <DbDataReader> ReaderExecuting( DbCommand command, CommandEventData eventData, InterceptionResult <DbDataReader> result) => result;
/// <summary> /// Called just before EF intends to call <see cref="DbCommand.ExecuteScalarAsync()" />. /// </summary> /// <param name="command"> The command. </param> /// <param name="eventData"> Contextual information about the command and execution. </param> /// <param name="result"> /// Represents the current result if one exists. /// This value will have <see cref="InterceptionResult{Object}.HasResult" /> set to true if some previous /// interceptor suppressed execution by calling <see cref="InterceptionResult{Object}.SuppressWithResult" />. /// 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{Object}.HasResult" /> is false, the EF will continue as normal. /// If <see cref="InterceptionResult{Object}.HasResult" /> is true, then EF will suppress the operation it /// was about to perform and use <see cref="InterceptionResult{Object}.Result" /> instead. /// A normal implementation of this method for any interceptor that is not attempting to change the result /// is to return the <paramref name="result" /> value passed in, often using <see cref="Task.FromResult{TResult}" /> /// </returns> public virtual Task <InterceptionResult <object> > ScalarExecutingAsync( DbCommand command, CommandEventData eventData, InterceptionResult <object> result, CancellationToken cancellationToken = default) => Task.FromResult(result);
/// <summary> /// Called just before EF intends to call <see cref="DbCommand.ExecuteReaderAsync()" />. /// </summary> /// <param name="command"> The command. </param> /// <param name="eventData"> Contextual information about the command and execution. </param> /// <param name="result"> /// Represents the current result if one exists. /// This value will have <see cref="InterceptionResult{DbDataReader}.HasResult" /> set to true if some previous /// interceptor suppressed execution by calling <see cref="InterceptionResult{DbDataReader}.SuppressWithResult" />. /// 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{DbDataReader}.HasResult" /> is false, the EF will continue as normal. /// If <see cref="InterceptionResult{DbDataReader}.HasResult" /> is true, then EF will suppress the operation it /// was about to perform and use <see cref="InterceptionResult{DbDataReader}.Result" /> instead. /// A normal implementation of this method for any interceptor that is not attempting to change the result /// is to return the <paramref name="result" /> value passed in, often using <see cref="Task.FromResult{TResult}" /> /// </returns> public virtual Task <InterceptionResult <DbDataReader> > ReaderExecutingAsync( DbCommand command, CommandEventData eventData, InterceptionResult <DbDataReader> result, CancellationToken cancellationToken = default) => Task.FromResult(result);