Method ToListAsync
- Namespace
- Open.Database.Extensions
- Assembly
- Open.Database.Extensions.Core.dll
ToListAsync<T>(DbCommand, CommandBehavior, Func<IDataRecord, ValueTask<T>>, CancellationToken)
Asynchronously iterates all records using an IDataReader and returns the desired results as a list.
public static ValueTask<List<T>> ToListAsync<T>(this DbCommand command, CommandBehavior behavior, Func<IDataRecord, ValueTask<T>> transform, CancellationToken cancellationToken = default)
Parameters
commandDbCommandThe DbCommand to generate a reader from.
behaviorCommandBehaviorThe behavior to use with the data reader.
transformFunc<IDataRecord, ValueTask<T>>The transform function to process each IDataRecord.
cancellationTokenCancellationTokenThe cancellation token.
Returns
Type Parameters
TThe return type of the transform function.
ToListAsync<T>(DbCommand, Func<IDataRecord, ValueTask<T>>, CommandBehavior, CancellationToken)
Asynchronously iterates all records using an IDataReader and returns the desired results as a list.
public static ValueTask<List<T>> ToListAsync<T>(this DbCommand command, Func<IDataRecord, ValueTask<T>> transform, CommandBehavior behavior = CommandBehavior.Default, CancellationToken cancellationToken = default)
Parameters
commandDbCommandThe DbCommand to generate a reader from.
transformFunc<IDataRecord, ValueTask<T>>The transform function to process each IDataRecord.
behaviorCommandBehaviorThe behavior to use with the data reader.
cancellationTokenCancellationTokenThe cancellation token.
Returns
Type Parameters
TThe return type of the transform function.
ToListAsync<T>(DbCommand, CommandBehavior, Func<IDataRecord, T>, bool, CancellationToken)
Asynchronously iterates all records using an IDataReader and returns the desired results as a list.
public static ValueTask<List<T>> ToListAsync<T>(this DbCommand command, CommandBehavior behavior, Func<IDataRecord, T> transform, bool useReadAsync = true, CancellationToken cancellationToken = default)
Parameters
commandDbCommandThe DbCommand to generate a reader from.
behaviorCommandBehaviorThe behavior to use with the data reader.
transformFunc<IDataRecord, T>The transform function to process each IDataRecord.
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
Type Parameters
TThe return type of the transform function.
ToListAsync<T>(DbCommand, CommandBehavior, Func<IDataRecord, T>, CancellationToken)
Asynchronously iterates all records using an IDataReader and returns the desired results as a list.
public static ValueTask<List<T>> ToListAsync<T>(this DbCommand command, CommandBehavior behavior, Func<IDataRecord, T> transform, CancellationToken cancellationToken = default)
Parameters
commandDbCommandThe DbCommand to generate a reader from.
behaviorCommandBehaviorThe behavior to use with the data reader.
transformFunc<IDataRecord, T>The transform function to process each IDataRecord.
cancellationTokenCancellationTokenThe cancellation token.
Returns
Type Parameters
TThe return type of the transform function.
ToListAsync<T>(DbCommand, Func<IDataRecord, T>, CommandBehavior, bool, CancellationToken)
Asynchronously iterates all records using an IDataReader and returns the desired results as a list.
public static ValueTask<List<T>> ToListAsync<T>(this DbCommand command, Func<IDataRecord, T> transform, CommandBehavior behavior = CommandBehavior.Default, bool useReadAsync = true, CancellationToken cancellationToken = default)
Parameters
commandDbCommandThe DbCommand to generate a reader from.
transformFunc<IDataRecord, T>The transform function to process each IDataRecord.
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
Type Parameters
TThe return type of the transform function.