Fauna v10 .NET/C# Driver 0.2.0-beta
 
Loading...
Searching...
No Matches
QuerySource.cs
Go to the documentation of this file.
1using System.Diagnostics.CodeAnalysis;
2using Fauna.Types;
3
4namespace Fauna.Linq;
5
6public abstract class QuerySource : IQuerySource
7{
8 [AllowNull]
9 internal DataContext Ctx { get; private protected set; }
10 [AllowNull]
11 internal Pipeline Pipeline { get; private protected set; }
12
13 internal void SetContext(DataContext ctx)
14 {
15 Ctx = ctx;
16 }
17
18 internal void SetQuery<TElem>(Query query)
19 {
20 Pipeline = new Pipeline(PipelineMode.Query, query, typeof(TElem), false, null, null);
21 }
22}
23
24public partial class QuerySource<T> : QuerySource, IQuerySource<T>
25{
26 internal QuerySource(DataContext ctx, Pipeline pl)
27 {
28 Ctx = ctx;
29 Pipeline = pl;
30 }
31
32 // Collection/Index DSLs are allowed to set _expr and _ctx in their own
33 // constructors, so they use this base one.
34 internal QuerySource() { }
35
36 public IAsyncEnumerable<Page<T>> PaginateAsync(QueryOptions? queryOptions = null, CancellationToken cancel = default)
37 {
38 var pe = Pipeline.GetExec(Ctx);
39 return pe.PagedResult<T>(queryOptions, cancel);
40 }
41
42 public IAsyncEnumerable<T> ToAsyncEnumerable(CancellationToken cancel = default) =>
43 PaginateAsync(cancel: cancel).FlattenAsync();
44
45 public IEnumerable<T> ToEnumerable() => new QuerySourceEnumerable(this);
46}
IEnumerable< T > ToEnumerable()
IAsyncEnumerable< Page< T > > PaginateAsync(QueryOptions? queryOptions=null, CancellationToken cancel=default)
IAsyncEnumerable< T > ToAsyncEnumerable(CancellationToken cancel=default)
Represents the abstract base class for constructing FQL queries.
Definition Query.cs:11
Represents the options for customizing Fauna queries.