コード例 #1
0
        public OrQuery MakeOrQuery(AndQuery andQuery)
        {
            var q = new OrQuery(_typeDescription.FullTypeName);

            q.Elements.Add(andQuery);

            return(q);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        /// <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);
        }
コード例 #4
0
        /// <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);
        }
コード例 #5
0
ファイル: QueryBuilder.cs プロジェクト: usinesoft/Cachalot
        /// <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);
        }
コード例 #6
0
        /// <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);
        }
コード例 #7
0
 public bool IsSubsetOf(AndQuery query)
 {
     return(query.Elements.All(e => Elements.Any(q => q.IsSubsetOf(e))));
 }