Reader Extensions. Get Field Value Async<T>(DbDataReader, String, CancellationToken) Method
Asynchronously gets the value of the specified column as the requested type.
public static System.Threading.Tasks.Task<T> GetFieldValueAsync<T> (this System.Data.Common.DbDataReader reader, string name, System.Threading.CancellationToken cancellationToken = null);
static member GetFieldValueAsync : System.Data.Common.DbDataReader * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'T>
The type of the value to be returned.
The data reader to get the column value from.
The name of the column.
An optional token to cancel the asynchronous operation.
The connection was dropped or closed during data retrieval.
The data reader was closed during the data retrieval.
There is no data ready to be read (for example, the first Read() hasn't been called, or it returned
Tried to read a previously-read column in sequential mode.
There was an asynchronous operation in progress. This applies to all Get_*_ methods when running in sequential mode, as they could be called while reading a stream.
The name specified is not a valid column name.
The value returned by the database doesn't match or cannot be cast to
This asynchronous method is only needed to avoid blocking the calling thread when the reader is created in sequential mode.
If sequential mode isn't specified, all column values should become available in memory each time ReadAsync completes, and calling the synchronous version of the method shouldn't block the calling thread.
The default implementation of this asynchronous method invokes its synchronous counterpart and returns a completed Task, potentially blocking the calling thread. The default implementation also returns a cancelled task if passed an already cancelled cancellation token.
Data providers that support asynchronous programming should override the default inmplementation using asynchronous I/O operations.
This method accepts a cancellation token that can be used to request the operation to be cancelled early. Implementations may ignore this request.
Other methods and properties of the DbDataReader object should not be invoked while the returned Task is not yet completed.