2using System.Collections.Generic;
4using System.Threading.Tasks;
19 private readonly Dictionary<string, bool> isLabel =
new Dictionary<string, bool>();
20 private readonly
string collectionName;
21 private readonly
string alias;
46 KeyValuePair<VariableReference, bool>[] Order,
ScriptNode Node)
57 IEnumerable<object> Objects = await
Database.
Find(this.collectionName, Offset, Top,
76 KeyValuePair<VariableReference, bool>[] Order,
ScriptNode Node)
80 if (Filter is
null && Offset == 0 && Top ==
int.MaxValue)
95 foreach (
object Obj
in Objects)
107 public Task
Update(
bool Lazy, IEnumerable<object> Objects)
117 public Task
Insert(
bool Lazy,
object Object)
132 get {
return string.Empty; }
140 get =>
string.IsNullOrEmpty(this.alias) ? this.collectionName : this.alias;
151 string.Compare(this.collectionName,
Name,
true) == 0 ||
152 string.Compare(this.alias,
Name,
true) == 0;
166 if (this.isLabel.TryGetValue(Label, out Result))
174 this.isLabel[Label] = Result;
189 StringBuilder sb =
new StringBuilder();
190 foreach (
string Field
in Fields)
191 sb.AppendLine(Field);
203 string Key =
"SQL.INDEX." + this.collectionName +
"." +
Name;
205 string[] Fields = s.Split(crlf, StringSplitOptions.RemoveEmptyEntries);
206 if (Fields.Length == 0)
215 private static readonly
char[] crlf =
new char[] {
'\r',
'\n' };
Static interface for database persistence. In order to work, a database provider has to be assigned t...
static Task< IEnumerable< object > > FindDelete(string Collection, params string[] SortOrder)
Finds objects in a given collection and deletes them in the same atomic operation.
static async Task DeleteLazy(object Object)
Deletes an object in the database, if unlocked. If locked, object will be deleted at next opportunity...
static Task RemoveIndex(string CollectionName, string[] FieldNames)
Removes an index from a collection, if one exist.
static Task< bool > IsLabel(string Collection, string Label)
Checks if a string is a label in a given collection.
static async Task InsertLazy(object Object)
Inserts an object into the database, if unlocked. If locked, object will be inserted at next opportun...
static Task AddIndex(string CollectionName, string[] FieldNames)
Adds an index to a collection, if one does not already exist.
static async Task UpdateLazy(object Object)
Updates an object in the database, if unlocked. If locked, object will be updated at next opportunity...
static async Task Update(object Object)
Updates an object in the database.
static Task< IEnumerable< object > > Find(string Collection, params string[] SortOrder)
Finds objects in a given collection.
static async Task Insert(object Object)
Inserts an object into the default collection of the database.
static Task DropCollection(string CollectionName)
Drops a collection, if it exist.
static async Task Clear(string CollectionName)
Clears a collection of all objects.
Base class for all filter classes.
Generic object. Contains a sequence of properties.
Static class managing persistent settings.
static async Task< string > GetAsync(string Key, string DefaultValue)
Gets a string-valued setting.
static async Task< bool > SetAsync(string Key, string Value)
Sets a string-valued setting.
Base class for all nodes in a parsed script tree.
Data Source defined by a collection name
async Task< bool > DropIndex(string Name)
Drops an index from the source.
CollectionSource(string CollectionName, string Alias)
Data Source defined by a collection name
Task Update(bool Lazy, IEnumerable< object > Objects)
Updates a set of objects.
async Task< bool > IsLabel(string Label)
Checks if the label is a label in the source.
async Task< int?> FindDelete(bool Lazy, int Offset, int Top, ScriptNode Where, Variables Variables, KeyValuePair< VariableReference, bool >[] Order, ScriptNode Node)
Finds and Deletes a set of objects.
Task Insert(bool Lazy, object Object)
Inserts an object.
async Task< IResultSetEnumerator > Find(int Offset, int Top, bool Generic, ScriptNode Where, Variables Variables, KeyValuePair< VariableReference, bool >[] Order, ScriptNode Node)
Finds objects matching filter conditions in Where .
async Task CreateIndex(string Name, string[] Fields)
Creates an index in the source.
string TypeName
Name of corresponding type.
string Name
Collection name or alias.
Task DropCollection()
Drops the collection from the source.
bool IsSource(string Name)
Checks if the name refers to the source.
string CollectionName
Name of corresponding collection.
Data Source defined by a type definition
Interface for data sources that can be used in SQL statements.