Method FirstOrdinalResultsAsync
- Namespace
- Open.Database.Extensions
- Assembly
- Open.Database.Extensions.Core.dll
FirstOrdinalResultsAsync(DbCommand, CommandBehavior, bool, CancellationToken)
Reads the first column from every record.
public static ValueTask<IEnumerable<object?>> FirstOrdinalResultsAsync(this DbCommand command, CommandBehavior behavior = CommandBehavior.SequentialAccess, bool useReadAsync = true, CancellationToken cancellationToken = default)
Parameters
commandDbCommandThe IDbCommand to generate a reader from.
behaviorCommandBehaviorThe behavior to use with the data reader.
useReadAsyncboolIf true (default) will iterate the results using .ReadAsync() otherwise will only Execute the reader asynchronously and then use .Read() to iterate the results but still allowing cancellation.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- ValueTask<IEnumerable<object>>
The enumerable of casted values.
Remarks
DBNull values are converted to null.
FirstOrdinalResultsAsync<T0>(DbCommand, CommandBehavior, bool, CancellationToken)
Reads the first column from every record.
public static ValueTask<IEnumerable<T0>> FirstOrdinalResultsAsync<T0>(this DbCommand command, CommandBehavior behavior = CommandBehavior.SequentialAccess, bool useReadAsync = true, CancellationToken cancellationToken = default)
Parameters
commandDbCommandThe IDbCommand to generate a reader from.
behaviorCommandBehaviorThe behavior to use with the data reader.
useReadAsyncboolIf true (default) will iterate the results using .ReadAsync() otherwise will only Execute the reader asynchronously and then use .Read() to iterate the results but still allowing cancellation.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- ValueTask<IEnumerable<T0>>
The enumerable of casted values.
Type Parameters
T0The expected type of the first ordinal.
Remarks
Any DBNull values are then converted to null and casted to type T0.