11 private bool _initialized =
false;
13 private IReadOnlyDictionary<Type, Collection> _collections;
20 internal Linq.LookupTable LookupTable {
get =>
new Linq.LookupTable(_ctx); }
25 _collections = collections.ToImmutableDictionary();
28 foreach (var col
in collections.Values)
30 ((Linq.QuerySource)col).SetContext(
this);
38 internal override Task<QuerySuccess<T>> QueryAsyncInternal<T>(
40 Serialization.IDeserializer<T> deserializer,
43 CancellationToken cancel)
45 CheckInitialization();
46 return _client.QueryAsyncInternal(query, deserializer, ctx, queryOptions, cancel);
51 [AttributeUsage(AttributeTargets.Class)]
54 internal readonly
string Name;
62 public interface Collection : Linq.IQuerySource
64 public string Name {
get; }
70 public string Name {
get; }
71 public Type
DocType {
get => typeof(Doc); }
75 var nameAttr = this.GetType().GetCustomAttribute<
NameAttribute>();
76 Name = nameAttr?.Name ?? typeof(Doc).Name;
77 SetQuery<Doc>(Linq.IntermediateQueryHelpers.CollectionAll(
this));
82 protected IndexCall Index(
string? name =
null, [CallerMemberName]
string?
auto =
null)
84 if (name is
null &&
auto is not
null)
86 name = FieldName.Canonical(
auto);
89 if (
string.IsNullOrEmpty(name))
90 throw new ArgumentException($
"{nameof(name)} cannot be null or empty.");
98 private readonly
string _name;
121 public interface Index : Linq.IQuerySource
132 public string Name {
get; }
133 public Type
DocType {
get => typeof(Doc); }
134 public object[]
Args {
get; }
142 SetQuery<Doc>(Linq.IntermediateQueryHelpers.CollectionIndex(
this));
148 CheckInitialization();
149 return (Col)_collections[typeof(Col)];
152 private void CheckInitialization()
156 throw new InvalidOperationException(
157 "Uninitialized context. DataContext sub-classes must be instantiated using a client's .DataContext() method.");
Index< Doc > Call(object a1, object a2, object a3)
Index< Doc > Call(object a1)
Index< Doc > Call(object a1, object a2)
Index< Doc > Call(object[] args)
IndexCall(Collection coll, string name, DataContext ctx)
NameAttribute(string name)
Col GetCollection< Col >()
IndexCall Index(string? name=null, [CallerMemberName] string? auto=null)