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
TThe 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
- FirstAsync(CancellationToken)
Asynchronously reads the first mapped row; throws if the query returns no rows.
- 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.
- SingleAsync(CancellationToken)
Asynchronously reads the only mapped row; throws if the query returns no rows or more than one.
- SingleOrDefaultAsync(CancellationToken)
Asynchronously reads the only mapped row.
- Skip(int)
Skips the first
countmapped rows.
- Take(int)
Limits the result to at most
countmapped rows.
- 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 valuevalueSelectorreturns 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 valuevalueSelectorreturns for the row.
- 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>.
- ToImmutableArrayAsync(CancellationToken)
Asynchronously reads every mapped row into a new ImmutableArray<T>.
- ToListAsync(CancellationToken)
Asynchronously reads every mapped row into a new List<T>.