1using System.Diagnostics;
2using System.Linq.Expressions;
3using System.Runtime.CompilerServices;
12public partial class QuerySource<T>
16 private LookupTable Lookup {
get => Ctx.LookupTable; }
24 return Chain<T>(q:
QH.MethodCall(
Query,
"distinct"));
31 return Chain<T>(q:
QH.MethodCall(
Query,
"order"));
38 return Chain<T>(q:
QH.MethodCall(
Query,
"order", SubQuery(keySelector)));
45 return Chain<T>(q:
QH.MethodCall(
Query,
"order",
QH.FnCall(
"desc", SubQuery(keySelector))));
52 return Chain<T>(q:
QH.MethodCall(
Query,
"order",
QH.Expr(
"desc(x => x)")));
57 Chain<T>(q:
QH.MethodCall(
Query,
"reverse"));
62 var pl = SelectCall(
Query, selector);
68 Chain<T>(q:
QH.MethodCall(
Query,
"drop",
QH.Const(count)));
72 Chain<T>(q:
QH.MethodCall(
Query,
"take",
QH.Const(count)));
76 Chain<T>(q: WhereCall(
Query, predicate));
81 public bool All(Expression<Func<T, bool>> predicate) => Execute<bool>(AllImpl(predicate));
83 public Task<bool>
AllAsync(Expression<Func<T, bool>> predicate, CancellationToken cancel =
default) =>
84 ExecuteAsync<bool>(AllImpl(predicate), cancel);
85 private Pipeline AllImpl(Expression<Func<T, bool>> predicate)
87 RequireQueryMode(
"All");
90 q:
QH.MethodCall(
Query,
"every", SubQuery(predicate)),
95 public bool Any() => Execute<bool>(AnyImpl(
null));
97 public Task<bool>
AnyAsync(CancellationToken cancel =
default) =>
98 ExecuteAsync<bool>(AnyImpl(
null), cancel);
100 public bool Any(Expression<Func<T, bool>> predicate) => Execute<bool>(AnyImpl(predicate));
102 public Task<bool>
AnyAsync(Expression<Func<T, bool>> predicate, CancellationToken cancel =
default) =>
103 ExecuteAsync<bool>(AnyImpl(predicate), cancel);
104 private Pipeline AnyImpl(Expression<Func<T, bool>>? predicate) =>
107 q:
QH.MethodCall(MaybeWhereCall(
Query, predicate),
"nonEmpty"),
111 public int Count() => Execute<int>(CountImpl(
null));
113 public Task<int>
CountAsync(CancellationToken cancel =
default) =>
114 ExecuteAsync<int>(CountImpl(
null), cancel);
116 public int Count(Expression<Func<T, bool>> predicate) => Execute<int>(CountImpl(predicate));
118 public Task<int>
CountAsync(Expression<Func<T, bool>> predicate, CancellationToken cancel =
default) =>
119 ExecuteAsync<int>(CountImpl(predicate), cancel);
120 private Pipeline CountImpl(Expression<Func<T, bool>>? predicate) =>
123 q:
QH.MethodCall(MaybeWhereCall(
Query, predicate),
"count"),
127 public T
First() => Execute<T>(FirstImpl(
null));
129 public Task<T>
FirstAsync(CancellationToken cancel =
default) =>
130 ExecuteAsync<T>(FirstImpl(
null), cancel);
132 public T
First(Expression<Func<T, bool>> predicate) => Execute<T>(FirstImpl(predicate));
134 public Task<T>
FirstAsync(Expression<Func<T, bool>> predicate, CancellationToken cancel =
default) =>
135 ExecuteAsync<T>(FirstImpl(predicate), cancel);
136 private Pipeline FirstImpl(Expression<Func<T, bool>>? predicate) =>
139 q:
QH.MethodCall(AbortIfEmpty(MaybeWhereCall(
Query, predicate)),
"first"));
145 ExecuteAsync<T?>(FirstOrDefaultImpl(
null), cancel);
147 public T?
FirstOrDefault(Expression<Func<T, bool>> predicate) => Execute<T?>(FirstOrDefaultImpl(predicate));
149 public Task<T?>
FirstOrDefaultAsync(Expression<Func<T, bool>> predicate, CancellationToken cancel =
default) =>
150 ExecuteAsync<T?>(FirstOrDefaultImpl(predicate), cancel);
151 private Pipeline FirstOrDefaultImpl(Expression<Func<T, bool>>? predicate) =>
154 q:
QH.MethodCall(MaybeWhereCall(
Query, predicate),
"first"),
159 public T
Last() => Execute<T>(LastImpl(
null));
161 public Task<T>
LastAsync(CancellationToken cancel =
default) =>
162 ExecuteAsync<T>(LastImpl(
null), cancel);
164 public T
Last(Expression<Func<T, bool>> predicate) => Execute<T>(LastImpl(predicate));
166 public Task<T>
LastAsync(Expression<Func<T, bool>> predicate, CancellationToken cancel =
default) =>
167 ExecuteAsync<T>(LastImpl(predicate), cancel);
168 private Pipeline LastImpl(Expression<Func<T, bool>>? predicate) =>
171 q:
QH.MethodCall(AbortIfEmpty(MaybeWhereCall(
Query, predicate)),
"last"));
177 ExecuteAsync<T?>(LastOrDefaultImpl(
null), cancel);
179 public T?
LastOrDefault(Expression<Func<T, bool>> predicate) => Execute<T?>(LastOrDefaultImpl(predicate));
181 public Task<T?>
LastOrDefaultAsync(Expression<Func<T, bool>> predicate, CancellationToken cancel =
default) =>
182 ExecuteAsync<T?>(LastOrDefaultImpl(predicate), cancel);
183 private Pipeline LastOrDefaultImpl(Expression<Func<T, bool>>? predicate) =>
186 q:
QH.MethodCall(MaybeWhereCall(
Query, predicate),
"last"),
191 public long LongCount() => Execute<long>(LongCountImpl(
null));
194 ExecuteAsync<long>(LongCountImpl(
null), cancel);
196 public long LongCount(Expression<Func<T, bool>> predicate) => Execute<long>(LongCountImpl(predicate));
198 public Task<long>
LongCountAsync(Expression<Func<T, bool>> predicate, CancellationToken cancel =
default) =>
199 ExecuteAsync<long>(LongCountImpl(predicate), cancel);
200 private Pipeline LongCountImpl(Expression<Func<T, bool>>? predicate) =>
203 q:
QH.MethodCall(MaybeWhereCall(
Query, predicate),
"count"),
206 private static readonly
Query _maxReducer =
QH.Expr(
"(a, b) => if (a >= b) a else b");
209 public T
Max() => Execute<T>(MaxImpl<T>(
null));
211 public Task<T>
MaxAsync(CancellationToken cancel =
default) =>
212 ExecuteAsync<T>(MaxImpl<T>(
null), cancel);
214 public R
Max<R>(Expression<Func<T, R>> selector) => Execute<R>(MaxImpl(selector));
216 public Task<R>
MaxAsync<R>(Expression<Func<T, R>> selector, CancellationToken cancel =
default) =>
217 ExecuteAsync<R>(MaxImpl(selector), cancel);
218 private Pipeline MaxImpl<R>(Expression<Func<T, R>>? selector, [CallerMemberName]
string callerName =
"")
220 RequireQueryMode(callerName);
223 q:
QH.MethodCall(MaybeMap(AbortIfEmpty(
Query), selector),
"reduce", _maxReducer),
227 private static readonly
Query _minReducer =
QH.Expr(
"(a, b) => if (a <= b) a else b");
230 public T
Min() => Execute<T>(MinImpl<T>(
null));
232 public Task<T>
MinAsync(CancellationToken cancel =
default) => ExecuteAsync<T>(MinImpl<T>(
null), cancel);
234 public R
Min<R>(Expression<Func<T, R>> selector) => Execute<R>(MinImpl(selector));
236 public Task<R>
MinAsync<R>(Expression<Func<T, R>> selector, CancellationToken cancel =
default) =>
237 ExecuteAsync<R>(MinImpl(selector), cancel);
238 private Pipeline MinImpl<R>(Expression<Func<T, R>>? selector, [CallerMemberName]
string callerName =
"")
240 RequireQueryMode(callerName);
243 q:
QH.MethodCall(MaybeMap(AbortIfEmpty(
Query), selector),
"reduce", _minReducer),
248 public double Average(Expression<Func<T, double>> selector) => Execute<double>(AverageImpl(selector));
250 public Task<double>
AverageAsync(Expression<Func<T, double>> selector, CancellationToken cancel =
default) =>
251 ExecuteAsync<double>(AverageImpl(selector), cancel);
253 private Pipeline AverageImpl<R>(Expression<Func<T, R>> selector)
255 RequireQueryMode(
"Average");
259 q:
QH.FnCall(
"Math.mean",
QH.MethodCall(
QH.MethodCall(AbortIfEmpty(
Query),
"map", SubQuery(selector)),
"toArray")),
264 public T
Single() => Execute<T>(SingleImpl(
null));
266 public Task<T>
SingleAsync(CancellationToken cancel =
default) => ExecuteAsync<T>(SingleImpl(
null), cancel);
268 public T
Single(Expression<Func<T, bool>> predicate) => Execute<T>(SingleImpl(predicate));
270 public Task<T>
SingleAsync(Expression<Func<T, bool>> predicate, CancellationToken cancel =
default) =>
271 ExecuteAsync<T>(SingleImpl(predicate), cancel);
272 private Pipeline SingleImpl(Expression<Func<T, bool>>? predicate) =>
275 q:
QH.MethodCall(AbortIfEmpty(Singularize(MaybeWhereCall(
Query, predicate))),
"first"));
280 public Task<T>
SingleOrDefaultAsync(CancellationToken cancel =
default) => ExecuteAsync<T>(SingleOrDefaultImpl(
null), cancel);
282 public T
SingleOrDefault(Expression<Func<T, bool>> predicate) => Execute<T>(SingleOrDefaultImpl(predicate));
284 public Task<T>
SingleOrDefaultAsync(Expression<Func<T, bool>> predicate, CancellationToken cancel =
default) =>
285 ExecuteAsync<T>(SingleOrDefaultImpl(predicate), cancel);
286 private Pipeline SingleOrDefaultImpl(Expression<Func<T, bool>>? predicate) =>
289 q:
QH.MethodCall(Singularize(MaybeWhereCall(
Query, predicate)),
"first"),
293 private static readonly
Query _sumReducer =
QH.Expr(
"(a, b) => a + b");
296 public int Sum(Expression<Func<T, int>> selector) => Execute<int>(SumImpl<int>(selector));
298 public Task<int>
SumAsync(Expression<Func<T, int>> selector, CancellationToken cancel =
default) =>
299 ExecuteAsync<int>(SumImpl<int>(selector), cancel);
301 public long Sum(Expression<Func<T, long>> selector) => Execute<long>(SumImpl<long>(selector));
303 public Task<long>
SumAsync(Expression<Func<T, long>> selector, CancellationToken cancel =
default) =>
304 ExecuteAsync<long>(SumImpl<long>(selector), cancel);
306 public double Sum(Expression<Func<T, double>> selector) => Execute<double>(SumImpl<double>(selector));
308 public Task<double>
SumAsync(Expression<Func<T, double>> selector, CancellationToken cancel =
default) =>
309 ExecuteAsync<double>(SumImpl<double>(selector), cancel);
310 private Pipeline SumImpl<R>(Expression<Func<T, R>> selector)
312 RequireQueryMode(
"Sum");
313 var seed = (typeof(R) == typeof(
int) || typeof(R) == typeof(
long)) ?
316 var mapped =
QH.MethodCall(
Query,
"map", SubQuery(selector));
319 q:
QH.MethodCall(mapped,
"fold", seed, _sumReducer),
325 private void RequireQueryMode([CallerMemberName]
string callerName =
"")
331 $
"Query is not pure: Earlier `Select` could not be translated to pure FQL.");
335 private R Execute<R>(Pipeline pl)
339 var res = ExecuteAsync<R>(pl);
343 catch (AggregateException ex)
345 throw TranslateException(ex.InnerExceptions.First());
349 private async Task<R> ExecuteAsync<R>(Pipeline pl, CancellationToken cancel =
default)
353 return await pl.GetExec(Ctx).Result<R>(queryOptions:
null, cancel: cancel);
355 catch (AggregateException ex)
357 throw TranslateException(ex.InnerExceptions.First());
361 private QuerySource<R> Chain<R>(
367 LambdaExpression? proj =
null) =>
368 new QuerySource<R>(Ctx, CopyPipeline(mode, q, ser, ety, enull, proj));
370 private Pipeline CopyPipeline(
376 LambdaExpression? proj =
null)
378 if (ser is not
null) Debug.Assert(ety is not
null);
380 var mode0 = mode ?? Pipeline.Mode;
381 var q0 = q ?? Pipeline.Query;
384 var (ety0, enull0, ser0, proj0) = ety is not
null ?
385 (ety, enull, ser, proj) :
387 Pipeline.ElemNullable,
388 Pipeline.ElemSerializer,
389 proj ?? Pipeline.ProjectExpr);
391 return new Pipeline(mode0, q0, ety0, enull0, ser0, proj0);
398 QH.Expr(
@"({ let s = (").Concat(setq).Concat(
@")
399 if (s.isEmpty()) abort(['empty'])
405 let s = (").Concat(setq).Concat(
@")
406 let s = if (s isa Set) s.toArray() else s
408 if (s.length > 1) abort(['not single'])
415 private Exception TranslateException(Exception ex) =>
421 "empty" =>
new InvalidOperationException(
"Empty set"),
422 "not single" =>
new InvalidOperationException(
"Set contains more than one element"),
428 private Query MaybeWhereCall(
Query callee, Expression? predicate, [CallerMemberName]
string callerName =
"") =>
429 predicate is
null ? callee : WhereCall(callee, predicate, callerName);
431 private Query MaybeMap(
Query setq, Expression? selector) =>
432 selector is
null ? setq :
QH.MethodCall(setq,
"map", SubQuery(selector));
434 private Query SubQuery(Expression expr) =>
435 new SubQuerySwitch(Ctx.LookupTable).Apply(expr);
437 private Query WhereCall(
Query callee, Expression predicate, [CallerMemberName]
string callerName =
"")
439 RequireQueryMode(callerName);
440 return QH.MethodCall(callee,
"where", SubQuery(predicate));
443 private Pipeline SelectCall(
Query callee, Expression proj, [CallerMemberName]
string callerName =
"")
445 var lambda = Expressions.UnwrapLambda(proj);
446 Debug.Assert(lambda is not
null, $
"lambda is {proj.NodeType}");
447 Debug.Assert(lambda.Parameters.Count() == 1);
452 Debug.Assert(Pipeline.ProjectExpr is not
null);
453 var prev = Pipeline.ProjectExpr;
454 var pbody = Expression.Invoke(lambda,
new Expression[] { prev.Body });
455 var plambda = Expression.Lambda(pbody, prev.Parameters);
457 return CopyPipeline(proj: plambda);
462 var lparam = lambda.Parameters.First()!;
463 var analysis =
new ProjectionAnalysisVisitor(MappingCtx, lparam);
464 analysis.Visit(lambda.Body);
468 if (lambda.Body is MemberExpression mexpr && mexpr.Expression == lparam)
470 Debug.Assert(!analysis.Escapes);
471 var info = MappingCtx.
GetInfo(lparam.Type);
472 var access = analysis.Accesses.First();
473 var field = Lookup.FieldLookup(access, lparam);
474 Debug.Assert(field is not
null);
477 q:
QH.MethodCall(callee,
"map",
QH.Expr($
".{field.Name}")),
478 ser: field.Serializer,
482 if (analysis.Escapes)
488 var accesses = analysis.Accesses.OrderBy(f => f.Name).ToArray();
489 var fields = accesses.Select(a => Lookup.FieldLookup(a, lparam)!);
492 var accs = fields.Select(f =>
QH.Expr($
"x.{f.Name}"));
493 var pquery =
QH.Expr(
"x => ").Concat(
QH.Array(accs));
496 var deser =
new ProjectionDeserializer(fields.Select(f => f.Serializer));
497 var ety = typeof(
object?[]);
500 var pparam = Expression.Parameter(typeof(
object?[]),
"x");
501 var rewriter =
new ProjectionRewriteVisitor(lparam, accesses, pparam);
502 var pbody = rewriter.Visit(lambda.Body);
503 var plambda = Expression.Lambda(pbody, pparam);
506 q:
QH.MethodCall(callee,
"map", pquery),
Fauna.Linq.IntermediateQueryHelpers QH
Represents an exception that occurs when the FQL abort function is called. This exception captures th...
object? GetData()
Retrieves the deserialized data associated with the abort operation as an object.
An abstract class representing a QuerySource for LINQ-style queries.
Task< int > CountAsync(CancellationToken cancel=default)
Applies a count of the elements and executes the query asynchronously. This is evaluated server-side....
Task< T?> FirstOrDefaultAsync(Expression< Func< T, bool > > predicate, CancellationToken cancel=default)
Applies the predicate, executes the query asynchronously, and obtains the first element in the result...
double Average(Expression< Func< T, double > > selector)
Calculates the mean average of values returned by a provided selector. This is evaluated server-side....
Task< bool > AllAsync(Expression< Func< T, bool > > predicate, CancellationToken cancel=default)
Applies each predicate and executes the query asynchronously. This is evaluated server-side....
Task< long > SumAsync(Expression< Func< T, long > > selector, CancellationToken cancel=default)
Asynchronously calculates the sum of values returned by a provided selector. This is evaluated server...
Task< T > SingleOrDefaultAsync(Expression< Func< T, bool > > predicate, CancellationToken cancel=default)
Applies the predicate and executes the query asynchronously. If the result is a single element,...
Task< T > FirstAsync(CancellationToken cancel=default)
Executes the query asynchronously and obtains the first element in the result. This is evaluated serv...
Task< T > FirstAsync(Expression< Func< T, bool > > predicate, CancellationToken cancel=default)
Applies the predicate, executes the query asynchronously, and obtains the first element in the result...
bool Any()
Determines if the result is not empty. This is evaluated server-side.True if the result contains any ...
double Sum(Expression< Func< T, double > > selector)
Calculates the sum of values returned by a provided selector. This is evaluated server-side....
T SingleOrDefault(Expression< Func< T, bool > > predicate)
Applies the predicate and executes the query. If the result is a single element, returns it....
Task< T > MinAsync(CancellationToken cancel=default)
Executes a query asynchronously and returns the minimum value in the result set. This is evaluated se...
Task< double > AverageAsync(Expression< Func< T, double > > selector, CancellationToken cancel=default)
Asynchronously calculates the mean average of values returned by a provided selector....
bool Any(Expression< Func< T, bool > > predicate)
Applies each predicate and executes the query. This is evaluated server-side.True if any predicate ev...
Task< T?> FirstOrDefaultAsync(CancellationToken cancel=default)
Executes the query asynchronously and obtains the first element in the result or the default value,...
Task< int > SumAsync(Expression< Func< T, int > > selector, CancellationToken cancel=default)
Asynchronously calculates the sum of values returned by a provided selector. This is evaluated server...
T Single()
Executes the query. If the result is a single element, returns it. Otherwise, throws an exception....
Task< int > CountAsync(Expression< Func< T, bool > > predicate, CancellationToken cancel=default)
Applies the predicate, applies a count, and executes the query asynchronously. This is evaluated serv...
IQuerySource< T > OrderByDescending< K >(Expression< Func< T, K > > keySelector)
Orders by descending according to the selector. This is evaluated server-side.This IQuerySource<T> in...
R Min< R >(Expression< Func< T, R > > selector)
Applies the selector, executes the query, and returns the minimum value in the result set....
Task< T > LastAsync(Expression< Func< T, bool > > predicate, CancellationToken cancel=default)
Applies the predicate, executes the query asynchronously, and obtains the last element in the result....
T? FirstOrDefault(Expression< Func< T, bool > > predicate)
Applies the predicate, executes the query, and obtains the first element in the result or the default...
T SingleOrDefault()
Executes the query. If the result is a single element, returns it. Otherwise, returns the default....
T First(Expression< Func< T, bool > > predicate)
Applies the predicate, executes the query, and obtains the first element in the result....
Task< T > LastAsync(CancellationToken cancel=default)
Executes the query asynchronously and obtains the last element in the result. This is evaluated serve...
IQuerySource< T > Reverse()
Reverses the order of the results. This is evaluated server-side.This IQuerySource<T> instance.
T Max()
Executes a query and returns the maximum value in the result set. This is evaluated server-side....
Task< R > MinAsync< R >(Expression< Func< T, R > > selector, CancellationToken cancel=default)
Applies the selector, executes the query asynchronously, and returns the minimum value in the result ...
IQuerySource< T > Skip(int count)
Skips the first N elements of the results. This is evaluated server-side.This IQuerySource<T> instanc...
Task< T > SingleOrDefaultAsync(CancellationToken cancel=default)
Executes the query asynchronously. If the result is a single element, returns it. Otherwise,...
IQuerySource< T > Where(Expression< Func< T, bool > > predicate)
Applies the predicate to the query. This is evaluated server-side.This IQuerySource<T> instance.
IQuerySource< T > OrderDescending()
Orders by descending. This is evaluated server-side.This IQuerySource<T> instance.
int Count()
Applies a count of the elements and executes the query. This is evaluated server-side....
T? LastOrDefault()
Executes the query and obtains the last element in the result or the default value,...
bool All(Expression< Func< T, bool > > predicate)
Applies each predicate and executes the query. This is evaluated server-side.True if every predicate ...
Task< R > MaxAsync< R >(Expression< Func< T, R > > selector, CancellationToken cancel=default)
Applies a selector, executes a query asynchronously, and returns the maximum value in the result set....
IQuerySource< T > Order()
Applies default ordering to the query. This is evaluated server-side.This IQuerySource<T> instance.
long LongCount(Expression< Func< T, bool > > predicate)
Applies the predicate, applies a count, and executes the query. This is evaluated server-side....
Task< T?> LastOrDefaultAsync(Expression< Func< T, bool > > predicate, CancellationToken cancel=default)
Applies the predicate, executes the query asynchronously and obtains the last element in the result o...
int Sum(Expression< Func< T, int > > selector)
Calculates the sum of values returned by a provided selector. This is evaluated server-side....
T Last()
Executes the query and obtains the last element in the result. This is evaluated server-side....
IQuerySource< T > Take(int count)
Takes the first N elements of the results. This is evaluated server-side.This IQuerySource<T> instanc...
Task< T > SingleAsync(CancellationToken cancel=default)
Executes the query asynchronously. If the result is a single element, returns it. Otherwise,...
T Single(Expression< Func< T, bool > > predicate)
Applies the predicate and executes the query. If the result is a single element, returns it....
IQuerySource< T > Distinct()
Obtains a distinct set of results. This is evaluated server-side.This IQuerySource<T> instance.
Task< long > LongCountAsync(CancellationToken cancel=default)
Applies a count of the elements and executes the query asynchronously. This is evaluated server-side....
Task< double > SumAsync(Expression< Func< T, double > > selector, CancellationToken cancel=default)
Asynchronously calculates the sum of values returned by a provided selector. This is evaluated server...
Task< T?> LastOrDefaultAsync(CancellationToken cancel=default)
Executes the query asynchronously and obtains the last element in the result or the default value,...
long LongCount()
Applies a count of the elements and executes the query. This is evaluated server-side....
T First()
Executes the query and obtains the first element in the result. This is evaluated server-side....
Task< T > SingleAsync(Expression< Func< T, bool > > predicate, CancellationToken cancel=default)
Applies the predicate and executes the query asynchronously. If the result is a single element,...
T? LastOrDefault(Expression< Func< T, bool > > predicate)
Applies the predicate, executes the query and obtains the last element in the result or the default v...
Task< bool > AnyAsync(Expression< Func< T, bool > > predicate, CancellationToken cancel=default)
Applies each predicate and executes the query asynchronously. This is evaluated server-side....
T Last(Expression< Func< T, bool > > predicate)
Applies the predicate, executes the query, and obtains the last element in the result....
IQuerySource< T > OrderBy< K >(Expression< Func< T, K > > keySelector)
Orders according to the selector. This is evaluated server-side.This IQuerySource<T> instance.
Task< T > MaxAsync(CancellationToken cancel=default)
Executes a query asynchronously and returns the maximum value in the result set. This is evaluated se...
T Min()
Executes a query and returns the minimum value in the result set. This is evaluated server-side....
Task< long > LongCountAsync(Expression< Func< T, bool > > predicate, CancellationToken cancel=default)
Applies the predicate, applies a count, and executes the query asynchronously. This is evaluated serv...
long Sum(Expression< Func< T, long > > selector)
Calculates the sum of values returned by a provided selector. This is evaluated server-side....
IQuerySource< R > Select< R >(Expression< Func< T, R > > selector)
Applies a projection to the query. This is evaluated server-side.This IQuerySource<T> instance.
Task< bool > AnyAsync(CancellationToken cancel=default)
Determines if the result is not empty asynchronously. This is evaluated server-side....
R Max< R >(Expression< Func< T, R > > selector)
Applies a selector, executes a query, and returns the maximum value in the result set....
int Count(Expression< Func< T, bool > > predicate)
Applies the predicate, applies a count, and executes the query. This is evaluated server-side....
T? FirstOrDefault()
Executes the query and obtains the first element in the result or the default value,...
A class representing the mapping context to be used during serialization and deserialization.
MappingInfo GetInfo(Type ty, string? colName=null)
Gets the MappingInfo for a given Type.
Represents the abstract base class for constructing FQL queries.
An interface for common static IQuerySource methods that are non-generic.
A generic interface that defines serialize and deserialize behavior for a specific type,...
PipelineMode
The mode of the query pipeline.
@ Project
When elements have local projection.
@ Scalar
When there is a final, non-enum result, no more transformations are allowed.