Table of Contents

Struct MappedReader<T>

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

A deferred, type-locked read over a data reader the caller owns. Terminals are methods here.

public readonly record struct MappedReader<T> : IEquatable<MappedReader<T>>

Type Parameters

T

The type each row is mapped to.

Implements
Inherited Members

Remarks

The reader belongs to the caller. A terminal never opens, closes or disposes it, and never calls NextResult() on it: it reads the rows of the current result set from the reader's current position and stops, leaving the reader open and positioned after that set's last row. A caller who wants the next result set calls NextResult() and maps again. The asynchronous terminals read the rows with Read(), as an expressive command does by default.

Skip(int) and Take(int) return the types of MappedQuery<T>; the SingleResult() they carry changes nothing here, since a reader view never reads through later result sets.

Methods

First()
FirstAsync(CancellationToken)

Asynchronously reads the first mapped row; throws if the query returns no rows.

FirstOrDefault()
FirstOrDefaultAsync(CancellationToken)

Asynchronously reads the first mapped row.

Read(Action<IEnumerable<T>>)

Passes the rows of the current result set to the handler.

ReadAsync(Func<IAsyncEnumerable<T>, CancellationToken, ValueTask>, CancellationToken)

Passes the rows of the current result set to the asynchronous handler.

ReadAsync<TResult>(Func<IAsyncEnumerable<T>, CancellationToken, ValueTask<TResult>>, CancellationToken)

Passes the rows of the current result set to the asynchronous handler and returns its result.

Read<TResult>(Func<IEnumerable<T>, TResult>)

Passes the rows of the current result set to the handler and returns its result.

Single()
SingleAsync(CancellationToken)

Asynchronously reads the only mapped row; throws if the query returns no rows or more than one.

SingleOrDefault()
SingleOrDefaultAsync(CancellationToken)

Asynchronously reads the only mapped row.

Skip(int)

Skips the first count mapped rows.

Take(int)

Limits the result to at most count mapped rows.

ToArray()
ToArrayAsync(CancellationToken)

Asynchronously reads every mapped row into a new array.

ToDictionaryAsync<TKey>(Func<T, TKey>, IEqualityComparer<TKey>?, CancellationToken)

Asynchronously reads every mapped row into a new Dictionary<TKey, TValue>, keyed by keySelector.

ToDictionaryAsync<TKey>(Func<T, TKey>, CancellationToken)

Asynchronously reads every mapped row into a new Dictionary<TKey, TValue>, keyed by keySelector.

ToDictionaryAsync<TKey, TValue>(Func<T, TKey>, Func<T, TValue>, IEqualityComparer<TKey>?, CancellationToken)

Asynchronously reads every mapped row into a new Dictionary<TKey, TValue>, keyed by keySelector, with the value valueSelector returns for the row.

ToDictionaryAsync<TKey, TValue>(Func<T, TKey>, Func<T, TValue>, CancellationToken)

Asynchronously reads every mapped row into a new Dictionary<TKey, TValue>, keyed by keySelector, with the value valueSelector returns for the row.

ToDictionary<TKey>(Func<T, TKey>, IEqualityComparer<TKey>?)
ToDictionary<TKey, TValue>(Func<T, TKey>, Func<T, TValue>, IEqualityComparer<TKey>?)
ToHashSet(IEqualityComparer<T>?)
ToHashSetAsync(IEqualityComparer<T>?, CancellationToken)

Asynchronously reads every mapped row into a new HashSet<T>.

ToHashSetAsync(CancellationToken)

Asynchronously reads every mapped row into a new HashSet<T>.

ToImmutableArray()
ToImmutableArrayAsync(CancellationToken)

Asynchronously reads every mapped row into a new ImmutableArray<T>.

ToList()
ToListAsync(CancellationToken)

Asynchronously reads every mapped row into a new List<T>.

See Also