Table of Contents

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

T

The 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

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 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.

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