Interface IResultSet<T>
Query result set.
Implements IAsyncEnumerable<T>: useawait foreach (var row in resultSet)
to consume,
or call ToListAsync() to get all rows as a list.
Can not be enumerated more than once. The implementation is lazy and retrieves data pages on demand
(while iterating with IAsyncEnumerable<T> or when ToListAsync() is called).
Page size is defined in PageSize.
public interface IResultSet<T> : IAsyncEnumerable<T>, IAsyncDisposable, IDisposable
Type Parameters
T
Row type.
- Inherited Members
Properties
AffectedRows
Gets the number of rows affected by the DML statement execution (such as "INSERT", "UPDATE", etc.), or 0 if the statement returns nothing (such as "ALTER TABLE", etc), or -1 if not applicable.
long AffectedRows { get; }
Property Value
HasRowSet
Gets a value indicating whether this result set contains a collection of rows.
bool HasRowSet { get; }
Property Value
Metadata
Gets result set metadata when HasRowSet is true
, otherwise null
.
IResultSetMetadata? Metadata { get; }
Property Value
WasApplied
Gets a value indicating whether a conditional query (such as "CREATE TABLE IF NOT EXISTS") was applied successfully.
bool WasApplied { get; }
Property Value
Methods
CollectAsync<TResult>(Func<int, TResult>, Action<TResult, T>)
Collects all result set rows into a container of the specified type.
ValueTask<TResult> CollectAsync<TResult>(Func<int, TResult> constructor, Action<TResult, T> accumulator)
Parameters
constructor
Func<int, TResult>Container constructor, accepts estimated capacity. Actual result set size may exceed specified capacity.
accumulator
Action<TResult, T>Accumulator, adds rows to the container.
Returns
- ValueTask<TResult>
resulting container.
Type Parameters
TResult
Resulting container type.
ToDictionaryAsync<TK, TV>(Func<T, TK>, Func<T, TV>, IEqualityComparer<TK>?)
Gets all result set rows as dictionary.
Can not be called multiple times - the underlying server-side result set is closed as soon as the last page of data is retrieved, and client-side buffer is also released to reduce memory usage.ValueTask<Dictionary<TK, TV>> ToDictionaryAsync<TK, TV>(Func<T, TK> keySelector, Func<T, TV> valSelector, IEqualityComparer<TK>? comparer = null) where TK : notnull
Parameters
keySelector
Func<T, TK>Key selector.
valSelector
Func<T, TV>Value selector.
comparer
IEqualityComparer<TK>Optional comparer.
Returns
- ValueTask<Dictionary<TK, TV>>
All result set rows as list.
Type Parameters
TK
Dictionary key type.
TV
Dictionary value type.
ToListAsync()
Gets all result set rows as list.
Can not be called multiple times - the underlying server-side result set is closed as soon as the last page of data is retrieved, and client-side buffer is also released to reduce memory usage.ValueTask<List<T>> ToListAsync()