Table of Contents

Method IterateWhileAsync

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

IterateWhileAsync(DbDataReader, Func<IDataRecord, bool>, CancellationToken)

Iterates an IDataReader while the predicate returns true.

public static ValueTask IterateWhileAsync(this DbDataReader reader, Func<IDataRecord, bool> predicate, CancellationToken cancellationToken = default)

Parameters

reader DbDataReader

The IDataReader to iterate.

predicate Func<IDataRecord, bool>

The handler function that processes each IDataRecord and decides if iteration should continue.

cancellationToken CancellationToken

An optional cancellation token for stopping the iteration.

Returns

ValueTask

IterateWhileAsync(DbDataReader, Func<IDataRecord, bool>, bool, CancellationToken)

Iterates an IDataReader while the predicate returns true.

public static ValueTask IterateWhileAsync(this DbDataReader reader, Func<IDataRecord, bool> predicate, bool useReadAsync, CancellationToken cancellationToken = default)

Parameters

reader DbDataReader

The DbDataReader to load data from.

predicate Func<IDataRecord, bool>

The handler function that processes each IDataRecord and decides if iteration should continue.

useReadAsync bool

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

Optional cancellation token.

Returns

ValueTask

IterateWhileAsync(IDataReader, Func<IDataRecord, ValueTask<bool>>, CancellationToken)

Iterates an IDataReader while the predicate returns true.

public static ValueTask IterateWhileAsync(this IDataReader reader, Func<IDataRecord, ValueTask<bool>> predicate, CancellationToken cancellationToken = default)

Parameters

reader IDataReader

The IDataReader to iterate.

predicate Func<IDataRecord, ValueTask<bool>>

The handler function that processes each IDataRecord and decides if iteration should continue.

cancellationToken CancellationToken

An optional cancellation token for stopping the iteration.

Returns

ValueTask

IterateWhileAsync(IDataReader, Func<IDataRecord, ValueTask<bool>>, bool, CancellationToken)

Iterates an IDataReader while the predicate returns true.

public static ValueTask IterateWhileAsync(this IDataReader reader, Func<IDataRecord, ValueTask<bool>> predicate, bool useReadAsync, CancellationToken cancellationToken = default)

Parameters

reader IDataReader

The IDataReader to iterate.

predicate Func<IDataRecord, ValueTask<bool>>

The handler function that processes each IDataRecord and decides if iteration should continue.

useReadAsync bool

If true will iterate the results using .ReadAsync() otherwise will only Execute the reader asynchronously and then use .Read() to iterate the results.

cancellationToken CancellationToken

Optional cancellation token.

Returns

ValueTask