src/Projac.Sql/Executors/SqlCommandExecutor.cs
/// <summary>
///     Executes the specified command asynchronously.
/// </summary>
/// <param name="command">The command.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
///     A <see cref="Task" /> that will return a <see cref="DbDataReader">data reader</see>.
/// </returns>
/// <exception cref="System.ArgumentNullException">Thrown when <paramref name="command" /> is <c>null</c>.</exception>
Executes the specified command asynchronously.
Executes the specified command asynchronously .
public async Task<DbDataReader> ExecuteReaderAsync(SqlQueryCommand command, CancellationToken cancellationToken)
        {
            if (command == null) throw new ArgumentNullException("command");
            var dbConnection = _dbProviderFactory.CreateConnection();
            dbConnection.ConnectionString = _connectionString;
            await dbConnection.OpenAsync(cancellationToken);
            try
            {
                using (var dbCommand = dbConnection.CreateCommand())
                {
                    dbCommand.Connection = dbConnection;
                    dbCommand.CommandTimeout = _commandTimeout;
                    dbCommand.CommandType = command.Type;
                    dbCommand.CommandText = command.Text;
                    dbCommand.Parameters.AddRange(command.Parameters);
                    return await dbCommand.ExecuteReaderAsync(CommandBehavior.CloseConnection | CommandBehavior.SequentialAccess, cancellationToken);
                }
            }
            catch
            {
                dbConnection.Close();
                throw;
            }
        }
public async Task < DbDataReader > ExecuteReaderAsync ( SqlQueryCommand command , CancellationToken cancellationToken ) { if ( command == null ) throw new ArgumentNullException ( " " ) ; var dbConnection = _dbProviderFactory . CreateConnection ( ) ; dbConnection . ConnectionString = _connectionString ; await dbConnection . OpenAsync ( cancellationToken ) ; try { using ( var dbCommand = dbConnection . CreateCommand ( ) ) { dbCommand . Connection = dbConnection ; dbCommand . CommandTimeout = _commandTimeout ; dbCommand . CommandType = command . Type ; dbCommand . CommandText = command . Text ; dbCommand . Parameters . AddRange ( command . Parameters ) ; return await dbCommand . ExecuteReaderAsync ( CommandBehavior . CloseConnection | CommandBehavior . SequentialAccess , cancellationToken ) ; } } catch { dbConnection . Close ( ) ; throw ; } }
Executes the specified command asynchronously.
Executes the specified command asynchronously .
A  that will return a data reader
A that will return a data reader
Thrown when  is null
Thrown when is null
command
SqlQueryCommand
None
cancellationToken
CancellationToken
The cancellation token.
The cancellation token .