internal static async Task <IResultSetEnumerator> Find(string Collection, int Offset, int Top, ScriptNode Where, Variables Variables, KeyValuePair <VariableReference, bool>[] Order, ScriptNode Node, string Name) { object[] FindParameters = new object[] { Collection, Offset, Top, TypeSource.Convert(Where, Variables, Name), TypeSource.Convert(Order) }; object Obj = FindMethod.Invoke(null, FindParameters); if (!(Obj is Task Task)) { throw new ScriptRuntimeException("Unexpected response.", Node); } await Task; PropertyInfo PI = Task.GetType().GetRuntimeProperty("Result"); if (PI is null) { throw new ScriptRuntimeException("Unexpected response.", Node); } Obj = PI.GetValue(Task); if (!(Obj is IEnumerable Enumerable)) { throw new ScriptRuntimeException("Unexpected response.", Node); } return(new SynchEnumerator(Enumerable.GetEnumerator())); }
/// <summary> /// Finds objects matching filter conditions in <paramref name="Where"/>. /// </summary> /// <param name="Offset">Offset at which to return elements.</param> /// <param name="Top">Maximum number of elements to return.</param> /// <param name="Where">Filter conditions.</param> /// <param name="Variables">Current set of variables.</param> /// <param name="Order">Order at which to order the result set.</param> /// <param name="Node">Script node performing the evaluation.</param> /// <returns>Enumerator.</returns> public async Task <IResultSetEnumerator> Find(int Offset, int Top, ScriptNode Where, Variables Variables, KeyValuePair <VariableReference, bool>[] Order, ScriptNode Node) { IEnumerable <object> Objects = await Database.Find(this.collectionName, Offset, Top, TypeSource.Convert(Where, Variables, this.Name), TypeSource.Convert(Order)); return(new SynchEnumerator(Objects.GetEnumerator())); }
/// <summary> /// Finds and Deletes a set of objects. /// </summary> /// <param name="Offset">Offset at which to return elements.</param> /// <param name="Top">Maximum number of elements to return.</param> /// <param name="Where">Filter conditions.</param> /// <param name="Variables">Current set of variables.</param> /// <param name="Order">Order at which to order the result set.</param> /// <param name="Node">Script node performing the evaluation.</param> public async Task <int> FindDelete(int Offset, int Top, ScriptNode Where, Variables Variables, KeyValuePair <VariableReference, bool>[] Order, ScriptNode Node) { Filter Filter = TypeSource.Convert(Where, Variables, this.Name); IEnumerable <object> Objects = await Database.FindDelete(this.collectionName, Offset, Top, Filter, TypeSource.Convert(Order)); int Count = 0; foreach (object Obj in Objects) { Count++; } return(Count); }
/// <summary> /// Finds and Deletes a set of objects. /// </summary> /// <param name="Offset">Offset at which to return elements.</param> /// <param name="Top">Maximum number of elements to return.</param> /// <param name="Where">Filter conditions.</param> /// <param name="Variables">Current set of variables.</param> /// <param name="Order">Order at which to order the result set.</param> /// <param name="Node">Script node performing the evaluation.</param> public async Task <int> FindDelete(int Offset, int Top, ScriptNode Where, Variables Variables, KeyValuePair <VariableReference, bool>[] Order, ScriptNode Node) { Filter Filter = TypeSource.Convert(Where, Variables, this.Name); object[] FindParameters = new object[] { Offset, Top, Filter, Convert(Order) }; object Obj = FindDeleteMethod.MakeGenericMethod(this.type).Invoke(null, FindParameters); if (!(Obj is Task Task)) { throw new ScriptRuntimeException("Unexpected response.", Node); } await Task; PropertyInfo PI = Task.GetType().GetRuntimeProperty("Result"); if (PI is null) { throw new ScriptRuntimeException("Unexpected response.", Node); } Obj = PI.GetValue(Task); if (!(Obj is IEnumerable <object> Objects)) { throw new ScriptRuntimeException("Unexpected response.", Node); } int Count = 0; foreach (object Obj2 in Objects) { Count++; } return(Count); }