Struct MappedTable<T>
- Namespace
- Open.Database.Extensions
- Assembly
- Open.Database.Extensions.Core.dll
A deferred, type-locked read over the rows of a DataTable. Terminals are methods here.
public readonly record struct MappedTable<T> : IEquatable<MappedTable<T>>
Type Parameters
TThe type each row is mapped to.
- Implements
- Inherited Members
Remarks
Each terminal reads the table's current rows through a new DataTableReader and disposes it. The table itself is not changed or cleared, so the view can be read more than once. The view never touches a connection and never calls NextResult(). The asynchronous terminals complete synchronously: the rows are already in memory.
Skip(int) and Take(int) return the types of MappedQuery<T>; the SingleResult() they carry changes nothing here, since a table has one result set.
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 table to the handler.
- ReadAsync(Func<IAsyncEnumerable<T>, CancellationToken, ValueTask>, CancellationToken)
Passes the rows of the table to the asynchronous handler.
- ReadAsync<TResult>(Func<IAsyncEnumerable<T>, CancellationToken, ValueTask<TResult>>, CancellationToken)
Passes the rows of the table to the asynchronous handler and returns its result.
- Read<TResult>(Func<IEnumerable<T>, TResult>)
Passes the rows of the table 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>.