/// <summary> /// Sends <see cref="IDbCommandInterceptor.ReaderExecuting" /> and /// <see cref="IDbCommandInterceptor.ReaderExecuted" /> to any <see cref="IDbCommandInterceptor" /> /// interceptors that are registered on <see cref="Interception" /> before/after making a /// call to <see cref="DbCommand.ExecuteReaderAsync(CommandBehavior, CancellationToken)" />. /// </summary> /// <remarks> /// Note that the result of executing the command is returned by this method. The result is not available /// in the interception context passed into this method since the interception context is cloned before /// being passed to interceptors. /// </remarks> /// <param name="command">The command on which the operation will be executed.</param> /// <param name="cancellationToken">The cancellation token for the asynchronous operation.</param> /// <param name="interceptionContext">Optional information about the context of the call being made.</param> /// <returns>The result of the operation, which may have been modified by interceptors.</returns> public virtual Task <DbDataReader> AsyncReader( DbCommand command, CancellationToken cancellationToken, DbCommandBaseInterceptionContext interceptionContext) { Check.NotNull(command, "command"); Check.NotNull(interceptionContext, "interceptionContext"); var clonedInterceptionContext = new DbCommandInterceptionContext <DbDataReader>(interceptionContext); if (!clonedInterceptionContext.IsAsync) { clonedInterceptionContext = clonedInterceptionContext.AsAsync(); } return(InternalDispatcher.DispatchAsync( () => command.ExecuteReaderAsync(clonedInterceptionContext.CommandBehavior, cancellationToken), clonedInterceptionContext, i => i.ReaderExecuting(command, clonedInterceptionContext), i => i.ReaderExecuted(command, clonedInterceptionContext))); }
/// <summary> /// Sends <see cref="IDbCommandInterceptor.ScalarExecuting" /> and /// <see cref="IDbCommandInterceptor.ScalarExecuted" /> to any <see cref="IDbCommandInterceptor" /> /// interceptors that are registered on <see cref="Interception" /> before/after making a /// call to <see cref="DbCommand.ExecuteScalarAsync(CancellationToken)" />. /// </summary> /// <remarks> /// Note that the result of executing the command is returned by this method. The result is not available /// in the interception context passed into this method since the interception context is cloned before /// being passed to interceptors. /// </remarks> /// <param name="command">The command on which the operation will be executed.</param> /// <param name="cancellationToken">The cancellation token for the asynchronous operation.</param> /// <param name="interceptionContext">Optional information about the context of the call being made.</param> /// <returns>The result of the operation, which may have been modified by interceptors.</returns> public virtual Task <object> AsyncScalar( DbCommand command, CancellationToken cancellationToken, DbCommandBaseInterceptionContext interceptionContext) { Check.NotNull(command, "command"); Check.NotNull(interceptionContext, "interceptionContext"); var clonedInterceptionContext = new DbCommandInterceptionContext <object>(interceptionContext); if (!clonedInterceptionContext.IsAsync) { clonedInterceptionContext = clonedInterceptionContext.AsAsync(); } return(InternalDispatcher.DispatchAsync( () => command.ExecuteScalarAsync(cancellationToken), clonedInterceptionContext, i => i.ScalarExecuting(command, clonedInterceptionContext), i => i.ScalarExecuted(command, clonedInterceptionContext))); }