1using System.Collections.Immutable;
2using System.Diagnostics.CodeAnalysis;
3using System.Reflection;
4using System.Runtime.CompilerServices;
18 private bool _initialized =
false;
20 private IReadOnlyDictionary<Type, ICollection> _collections =
null!;
22 private Client _client =
null!;
27 internal Linq.LookupTable LookupTable {
get =>
new Linq.LookupTable(_ctx); }
32 _collections = collections.ToImmutableDictionary();
35 foreach (var col
in collections.Values)
37 ((Linq.QuerySource)col).SetContext(
this);
45 internal override Task<QuerySuccess<T>> QueryAsyncInternal<T>(
47 Serialization.ISerializer<T> serializer,
50 CancellationToken cancel)
52 CheckInitialization();
53 return _client.QueryAsyncInternal(query, serializer, ctx, queryOptions, cancel);
56 internal override IAsyncEnumerator<Event<T>> SubscribeStreamInternal<T>(
59 CancellationToken cancel =
default)
61 CheckInitialization();
62 return _client.SubscribeStreamInternal<T>(eventSource, ctx, cancel);
65 internal override IAsyncEnumerator<FeedPage<T>> SubscribeFeedInternal<T>(
68 CancellationToken cancel =
default)
70 CheckInitialization();
71 return _client.SubscribeFeedInternal<T>(eventSource, ctx, cancel);
80 [AttributeUsage(AttributeTargets.Class)]
83 internal readonly
string Name;
128 var nameAttr = this.GetType().GetCustomAttribute<
NameAttribute>();
129 Name = nameAttr?.Name ?? typeof(Doc).Name;
130 SetQuery<Doc>(Linq.IntermediateQueryHelpers.CollectionAll(
this));
144 protected IndexCall Index(
string? name =
null, [CallerMemberName]
string?
auto =
null)
146 if (name is
null &&
auto is not
null)
148 name = FieldName.Canonical(
auto);
151 if (
string.IsNullOrEmpty(name))
163 private readonly
string _name;
266 SetQuery<Doc>(Linq.IntermediateQueryHelpers.CollectionIndex(
this));
330 public T
Call(
object a1,
object a2) =>
Call(
new[] { a1, a2 });
339 public T
Call(
object a1,
object a2,
object a3) =>
Call(
new[] { a1, a2, a3 });
376 public async Task<T>
CallAsync(
object a1,
object a2,
object a3) => await
CallAsync(
new[] { a1, a2, a3 });
385 var q = Linq.IntermediateQueryHelpers.Function(
Name, args);
386 return (await _ctx.QueryAsync<T>(q)).Data;
400 var fnName = name ==
"" ? callerName : name;
411 CheckInitialization();
412 return (Col)_collections[typeof(Col)];
415 private void CheckInitialization()
419 throw new InvalidOperationException(
420 "Uninitialized context. DataContext sub-classes must be instantiated using a client's .DataContext() method.");
System.ArgumentException ArgumentException
The base class for Client and DataContext.
Represents a client for interacting with a Fauna.
Represents the options for customizing Fauna queries.
A class representing an index call.
Index< Doc > Call(object a1, object a2, object a3)
Invokes an index.
IndexCall(ICollection coll, string name, DataContext ctx)
Initializes an index call.
Index< Doc > Call()
Invokes an index.
Index< Doc > Call(object a1, object a2)
Invokes an index.
Index< Doc > Call(object a1)
Invokes an index.
Index< Doc > Call(object[] args)
Invokes an index.
An abstract collection. This should be implemented for each collection in the database.
Collection()
Initializes a new collection with a name set to the NameAttribute, or the name of ....
IndexCall Index(string? name=null, [CallerMemberName] string? auto=null)
Initializes an index associated with the collection. The name of the index can be assigned,...
Type DocType
The .NET type associated with documents in the collection.
string Name
The collection name.
A class representing a function call.
T Call(object a1, object a2, object a3)
Calls the function.
T Call()
Calls the function.
string Name
The name of the function.
async Task< T > CallAsync(object a1)
Calls the function asynchronously.
async Task< T > CallAsync(object[] args)
Calls the function asynchronously.
T Call(object a1)
Calls the function.
async Task< T > CallAsync()
Calls the function asynchronously.
FunctionCall(string name, DataContext ctx)
Initializes a function call.
async Task< T > CallAsync(object a1, object a2, object a3)
Calls the function asynchronously.
async Task< T > CallAsync(object a1, object a2)
Calls the function asynchronously.
T Call(object a1, object a2)
Calls the function.
T Call(object[] args)
Calls the function.
A class representing an index query source.
Type DocType
The return type of the index.
object[] Args
An index argument array.
string Name
The name of the index.
An attribute representing a collection name.
NameAttribute(string name)
Initializes a NameAttribute.
An abstract class representing a DataContext. This is a special type of Fauna client that can be used...
Col GetCollection< Col >()
Gets a collection of type Col .
FunctionCall< T > Fn< T >(string name="", [CallerMemberName] string callerName="")
A helper method to declare new function calls.
An abstract class representing a QuerySource for LINQ-style queries.
A class representing the mapping context to be used during serialization and deserialization.
Represents the abstract base class for constructing FQL queries.
Represents a Fauna EventSource for initializing Streams and Feeds.
An interface for a Fauna collection within a DataContext.
Type DocType
The .NET type associated with documents in the collection.
string Name
The collection name.
An interface representing a function.
object[] Args
An array of arguments for the function.
string Name
The name of the function.
An interface representing an index query source.
string Name
The name of the index.
Type DocType
The return type of the index.
object[] Args
An index argument array.
An interface for common static IQuerySource methods that are non-generic.