Fauna v10 .NET/C# Driver 1.0.0
 
Loading...
Searching...
No Matches
QuerySourceExtensions.cs
Go to the documentation of this file.
1namespace Fauna.Linq;
2
3internal static class QuerySourceExtensions
4{
5 public static Dictionary<K, V> ToDictionary<K, V>(this IQuerySource<ValueTuple<K, V>> src) where K : notnull =>
6 src.ToDictionary(t => t.Item1, t => t.Item2);
7 public static Task<Dictionary<K, V>> ToDictionaryAsync<K, V>(this IQuerySource<ValueTuple<K, V>> src, CancellationToken cancel = default) where K : notnull =>
8 src.ToDictionaryAsync(t => t.Item1, t => t.Item2, cancel);
9
10 public static Dictionary<K, V> ToDictionary<K, V>(this IQuerySource<ValueTuple<K, V>> src, IEqualityComparer<K>? comparer) where K : notnull =>
11 src.ToDictionary(t => t.Item1, t => t.Item2, comparer);
12 public static Task<Dictionary<K, V>> ToDictionaryAsync<K, V>(this IQuerySource<ValueTuple<K, V>> src, IEqualityComparer<K>? comparer, CancellationToken cancel = default) where K : notnull =>
13 src.ToDictionaryAsync(t => t.Item1, t => t.Item2, comparer, cancel);
14
15 public static int Sum(this IQuerySource<int> src) => src.Sum(x => x);
16 public static Task<int> SumAsync(this IQuerySource<int> src, CancellationToken cancel = default) =>
17 src.SumAsync(x => x, cancel);
18
19 public static long Sum(this IQuerySource<long> src) => src.Sum(x => x);
20 public static Task<long> SumAsync(this IQuerySource<long> src, CancellationToken cancel = default) =>
21 src.SumAsync(x => x, cancel);
22
23 public static double Sum(this IQuerySource<double> src) => src.Sum(x => x);
24 public static Task<double> SumAsync(this IQuerySource<double> src, CancellationToken cancel = default) =>
25 src.SumAsync(x => x, cancel);
26
27 public static double Average(this IQuerySource<double> src) => src.Average(x => x);
28 public static Task<double> AverageAsync(this IQuerySource<double> src, CancellationToken cancel = default) =>
29 src.AverageAsync(x => x, cancel);
30}