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