public OrQuery MakeOrQuery(AndQuery andQuery) { var q = new OrQuery(_typeDescription.FullTypeName); q.Elements.Add(andQuery); return(q); }
public OrQuery MakeOrQuery(AtomicQuery atomicQuery) { var orQuery = new OrQuery(_typeDescription.FullTypeName); var andQuery = new AndQuery(); andQuery.Elements.Add(atomicQuery); orQuery.Elements.Add(andQuery); return(orQuery); }
/// <summary> /// Crate o query of the type "where IndexKey oper value" /// </summary> /// <param name="keyName"></param> /// <param name="value"></param> /// <param name="oper"></param> /// <returns></returns> public OrQuery GetMany(string keyName, object value, QueryOperator oper = QueryOperator.Eq) { var keyValue = _typeDescription.MakeIndexKeyValue(keyName, value); var query = new OrQuery(_typeDescription.FullTypeName); var andQuery = new AndQuery(); query.Elements.Add(andQuery); andQuery.Elements.Add(new AtomicQuery(keyValue, oper)); return(query); }
/// <summary> /// Get one by primary key /// </summary> /// <param name="value"></param> /// <returns></returns> public OrQuery GetOne(object value) { var keyValue = _typeDescription.MakePrimaryKeyValue(value); var query = new OrQuery(_typeDescription.FullTypeName); var andQuery = new AndQuery(); query.Elements.Add(andQuery); andQuery.Elements.Add(new AtomicQuery(keyValue)); return(query); }
/// <summary> /// Get one by primary key /// </summary> /// <param name="value"></param> /// <returns></returns> public OrQuery GetOne(object value) { var keyValue = value as KeyValue ?? new KeyValue(value, _collectionSchema.PrimaryKeyField); var query = new OrQuery(_collectionSchema.CollectionName); var andQuery = new AndQuery(); query.Elements.Add(andQuery); andQuery.Elements.Add(new AtomicQuery(_collectionSchema.PrimaryKeyField, keyValue)); return(query); }
/// <summary> /// Get many by multiple indexes /// </summary> /// <param name="binaryExpressions">a string formatted like "key operator value" </param> /// <returns></returns> public OrQuery GetMany(params string[] binaryExpressions) { var query = new OrQuery(_typeDescription.FullTypeName); var andQuery = new AndQuery(); query.Elements.Add(andQuery); foreach (var expression in binaryExpressions) { var q = StringToQuery(expression); andQuery.Elements.Add(q); } QueryHelper.OptimizeQuery(query); return(query); }
public bool IsSubsetOf(AndQuery query) { return(query.Elements.All(e => Elements.Any(q => q.IsSubsetOf(e)))); }