Skip to content

ExecuteReaderAsync Method ​

Definition ​

  • Namespace: JASE.Database
  • Assembly: JASE.Database.dll

Overloads ​

NameDescription
Task<Reader> ExecuteReaderAsync(ISqlStatement statement, bool doFirstRead = null, bool allowBatch = null, CommandType commandType = null, bool enableReaderTracking = null, int commandTimeout = null, CancellationToken cancellationToken = null)Executes a database query asynchronously and returns a Reader to read the results.
Task<Reader> ExecuteReaderAsync(string command, IReadOnlyList<IParameter> parameters = null, bool doFirstRead = null, bool allowBatch = null, CommandType commandType = null, bool enableReaderTracking = null, int commandTimeout = null, CancellationToken cancellationToken = null)Executes a database query asynchronously and returns a Reader to read the results.

Task<Reader> ExecuteReaderAsync(ISqlStatement statement, bool doFirstRead = null, bool allowBatch = null, CommandType commandType = null, bool enableReaderTracking = null, int commandTimeout = null, CancellationToken cancellationToken = null) ​

csharp
Task<Reader> ExecuteReaderAsync(ISqlStatement statement, bool doFirstRead = null, bool allowBatch = null, CommandType commandType = null, bool enableReaderTracking = null, int commandTimeout = null, CancellationToken cancellationToken = null)

Executes a database query asynchronously and returns a Reader to read the results.

Parameters ​

NameDescription
allowBatchIf true, allows batch SQL statements; otherwise, throws if a batch is detected.
cancellationTokenA token to cancel the operation.
commandTimeoutThe command timeout in seconds, or -1 to use the default.
commandTypeThe type of command (e.g., Text, StoredProcedure).
doFirstReadIf true, reads the first row of the result set asynchronously.
enableReaderTrackingIf , tracks the returned Reader instance so it can be managed and disposed by the connection/session lifecycle; otherwise, the caller is solely responsible for disposing the reader.
statementThe prepared SQL statement to execute

Returns ​

A Reader containing the query results.

Task<Reader> ExecuteReaderAsync(string command, IReadOnlyList<IParameter> parameters = null, bool doFirstRead = null, bool allowBatch = null, CommandType commandType = null, bool enableReaderTracking = null, int commandTimeout = null, CancellationToken cancellationToken = null) ​

csharp
Task<Reader> ExecuteReaderAsync(string command, IReadOnlyList<IParameter> parameters = null, bool doFirstRead = null, bool allowBatch = null, CommandType commandType = null, bool enableReaderTracking = null, int commandTimeout = null, CancellationToken cancellationToken = null)

Executes a database query asynchronously and returns a Reader to read the results.

Parameters ​

NameDescription
allowBatchIf true, allows batch SQL statements; otherwise, throws if a batch is detected.
cancellationTokenA token to cancel the operation.
commandThe SQL command or stored procedure name to execute.
commandTimeoutThe command timeout in seconds, or -1 to use the default.
commandTypeThe type of command (e.g., Text, StoredProcedure).
doFirstReadIf true, reads the first row of the result set asynchronously.
enableReaderTrackingIf , tracks the returned Reader instance so it can be managed and disposed by the connection/session lifecycle; otherwise, the caller is solely responsible for disposing the reader.
parametersThe parameters to bind to the command, if any.

Returns ​

A Reader containing the query results.

Remarks ​

When parameters is null and command is built from external input, callers must treat this as a trusted-SQL path (SQL injection risk). Prefer parameterized commands.