Table of Contents

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

command DbCommand

The DbCommand to generate a reader from.

behavior CommandBehavior

The behavior to use with the data reader.

transform Func<IDataRecord, ValueTask<T>>

The transform function to process each IDataRecord.

cancellationToken CancellationToken

The cancellation token.

Returns

ValueTask<List<T>>

A task containing a list of all results.

Type Parameters

T

The 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

command DbCommand

The DbCommand to generate a reader from.

transform Func<IDataRecord, ValueTask<T>>

The transform function to process each IDataRecord.

behavior CommandBehavior

The behavior to use with the data reader.

cancellationToken CancellationToken

The cancellation token.

Returns

ValueTask<List<T>>

A task containing a list of all results.

Type Parameters

T

The 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

command DbCommand

The DbCommand to generate a reader from.

behavior CommandBehavior

The behavior to use with the data reader.

transform Func<IDataRecord, T>

The transform function to process each IDataRecord.

useReadAsync bool

If 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.

cancellationToken CancellationToken

The cancellation token.

Returns

ValueTask<List<T>>

A task containing a list of all results.

Type Parameters

T

The 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

command DbCommand

The DbCommand to generate a reader from.

behavior CommandBehavior

The behavior to use with the data reader.

transform Func<IDataRecord, T>

The transform function to process each IDataRecord.

cancellationToken CancellationToken

The cancellation token.

Returns

ValueTask<List<T>>

A task containing a list of all results.

Type Parameters

T

The 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

command DbCommand

The DbCommand to generate a reader from.

transform Func<IDataRecord, T>

The transform function to process each IDataRecord.

behavior CommandBehavior

The behavior to use with the data reader.

useReadAsync bool

If 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.

cancellationToken CancellationToken

The cancellation token.

Returns

ValueTask<List<T>>

A task containing a list of all results.

Type Parameters

T

The return type of the transform function.