1using System.Collections;
21 public async Task<List<T>>
ToListAsync(CancellationToken cancel =
default)
23 var ret =
new List<T>();
38 public async Task<T[]>
ToArrayAsync(CancellationToken cancel =
default) =>
51 public Task<HashSet<T>>
ToHashSetAsync(CancellationToken cancel =
default) =>
67 public async Task<HashSet<T>>
ToHashSetAsync(IEqualityComparer<T>? comparer, CancellationToken cancel =
default)
69 var ret =
new HashSet<T>(comparer);
82 public Dictionary<K, V>
ToDictionary<K, V>(Func<T, K> getKey, Func<T, V> getValue) where K : notnull =>
83 ToDictionary(getKey, getValue,
null);
94 public Task<Dictionary<K, V>>
ToDictionaryAsync<K, V>(Func<T, K> getKey, Func<T, V> getValue, CancellationToken cancel =
default) where K : notnull =>
95 ToDictionaryAsync(getKey, getValue,
null, cancel);
106 public Dictionary<K, V>
ToDictionary<K, V>(Func<T, K> getKey, Func<T, V> getValue, IEqualityComparer<K>? comparer) where K : notnull =>
107 ToEnumerable().ToDictionary(getKey, getValue, comparer);
119 public async Task<Dictionary<K, V>>
ToDictionaryAsync<K, V>(Func<T, K> getKey, Func<T, V> getValue, IEqualityComparer<K>? comparer, CancellationToken cancel =
default) where K : notnull
121 var ret =
new Dictionary<K, V>(comparer);
130 public record
struct QuerySourceEnumerable(
QuerySource<T> Source) : IEnumerable<T>
136 public IEnumerator<T> GetEnumerator()
138 var pe = Source.PaginateAsync().GetAsyncEnumerator();
141 var mv = pe.MoveNextAsync().AsTask();
145 var page = pe.Current;
147 foreach (var e
in page.Data)
152 mv = pe.MoveNextAsync().AsTask();
156 finally { pe.DisposeAsync(); }
159 IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
An abstract class representing a QuerySource for LINQ-style queries.
async Task< HashSet< T > > ToHashSetAsync(IEqualityComparer< T >? comparer, CancellationToken cancel=default)
Executes the query asynchronously and converts the results to a HashSet<T>.
HashSet< T > ToHashSet()
Executes the query synchronously and converts the results to a HashSet<T>.
IEnumerable< T > ToEnumerable()
Executes a query.
T[] ToArray()
Executes the query synchronously and converts the results to a T:T[].
Task< Dictionary< K, V > > ToDictionaryAsync< K, V >(Func< T, K > getKey, Func< T, V > getValue, CancellationToken cancel=default)
Executes the query asynchronously and converts the results to a Dictionary<K,V>.
Task< HashSet< T > > ToHashSetAsync(CancellationToken cancel=default)
Executes the query asynchronously and converts the results to a HashSet<T>.
HashSet< T > ToHashSet(IEqualityComparer< T >? comparer)
Executes the query synchronously and converts the results to a HashSet<T> using a comparer.
async Task< T[]> ToArrayAsync(CancellationToken cancel=default)
Executes the query asynchronously and converts the results to a T:T[].
List< T > ToList()
Executes the query synchronously and converts the results to a List<T>.
Dictionary< K, V > ToDictionary< K, V >(Func< T, K > getKey, Func< T, V > getValue)
Executes the query synchronously and converts the results to a Dictionary<K,V>.
async Task< List< T > > ToListAsync(CancellationToken cancel=default)
Executes the query asynchronously and converts the results to a List<T>.
IAsyncEnumerable< T > ToAsyncEnumerable(CancellationToken cancel=default)
Executes a query asynchronously.