Table of Contents

Method ToListAsync

Namespace
Open.Database.Extensions
Assembly
Open.Database.Extensions.Core.dll

ToListAsync<T>(DbDataReader, Func<IDataRecord, T>, CancellationToken)

Asynchronously iterates all records using the data reader and returns the desired results as a list.

public static ValueTask<List<T>> ToListAsync<T>(this DbDataReader reader, Func<IDataRecord, T> transform, CancellationToken cancellationToken = default)

Parameters

reader DbDataReader

The SqlDataReader to read from.

transform Func<IDataRecord, T>

The transform function to process each IDataRecord.

cancellationToken CancellationToken

Optional 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>(DbDataReader, Func<IDataRecord, ValueTask<T>>, CancellationToken)

Asynchronously iterates all records using the data reader and returns the desired results as a list.

public static ValueTask<List<T>> ToListAsync<T>(this DbDataReader reader, Func<IDataRecord, ValueTask<T>> transform, CancellationToken cancellationToken = default)

Parameters

reader DbDataReader

The SqlDataReader to read from.

transform Func<IDataRecord, ValueTask<T>>

The transform function to process each IDataRecord.

cancellationToken CancellationToken

Optional cancellation token.

Returns

ValueTask<List<T>>

A task containing a list of all results.

Type Parameters

T

The return type of the transform function.