Beispiel #1
0
        /**
         * Return a new query based on this query with an additional where clause added.
         * @param json Json representation of the where clause.
         * @return A new EntityQuery.
         */
        public EntityQuery Where(string json)
        {
            var qmap = JsonConvert.DeserializeObject <Dictionary <string, object> >(json);
            var pred = BasePredicate.PredicateFromMap(qmap);

            return(this.Where(pred));
        }
Beispiel #2
0
        /**
         * Materializes the serialized json representation of an EntityQuery.
         * @param json The serialized json version of the EntityQuery.
         */
        public EntityQuery(string json)
        {
            if (json == null || json.Length == 0)
            {
                return;
            }
            Dictionary <string, object> qmap;

            try {
                var dmap = JsonHelper.Deserialize(json);
                qmap = (Dictionary <string, object>)dmap;
            } catch (Exception) {
                throw new Exception(
                          "This EntityQuery ctor requires a valid json string. The following is not json: "
                          + json);
            }

            this._resourceName       = GetMapValue <string>(qmap, "resourceName");
            this._skipCount          = GetMapInt(qmap, "skip");
            this._takeCount          = GetMapInt(qmap, "take");
            this._wherePredicate     = BasePredicate.PredicateFromMap(GetMapValue <Dictionary <string, object> >(qmap, "where"));
            this._orderByClause      = OrderByClause.From(GetMapValue <List <object> >(qmap, "orderBy"));
            this._selectClause       = SelectClause.From(GetMapValue <List <object> >(qmap, "select"));
            this._expandClause       = ExpandClause.From(GetMapValue <List <object> >(qmap, "expand"));
            this._parameters         = GetMapValue <Dictionary <string, object> >(qmap, "parameters");
            this._inlineCountEnabled = GetMapValue <bool?>(qmap, "inlineCount");
        }
Beispiel #3
0
        public static IQueryable ApplyWhere(IQueryable source, Type elementType, BasePredicate predicate)
        {
            var method     = TypeFns.GetMethodByExample((IQueryable <string> q) => q.Where(s => s != null), elementType);
            var lambdaExpr = predicate.ToLambda(elementType);
            var func       = BuildIQueryableFunc(elementType, method, lambdaExpr);

            return(func(source));
        }
Beispiel #4
0
 /**
  * Copy constructor
  * @param query
  */
 public EntityQuery(EntityQuery query)
 {
     this._resourceName       = query._resourceName;
     this._skipCount          = query._skipCount;
     this._takeCount          = query._takeCount;
     this._wherePredicate     = query._wherePredicate;
     this._orderByClause      = query._orderByClause;
     this._selectClause       = query._selectClause;
     this._expandClause       = query._expandClause;
     this._inlineCountEnabled = query._inlineCountEnabled;
     this._parameters         = query._parameters;
 }
Beispiel #5
0
        /**
         * Return a new query based on this query with an additional where clause added.
         * @param predicate A Predicate representing the where clause to add.
         * @return A new EntityQuery.
         */
        public EntityQuery Where(BasePredicate predicate)
        {
            var eq = new EntityQuery(this);

            if (eq._wherePredicate == null)
            {
                eq._wherePredicate = predicate;
            }
            else if (eq._wherePredicate.Operator == Operator.And)
            {
                var andOrPred = (AndOrPredicate)eq._wherePredicate;
                var preds     = new List <BasePredicate>(andOrPred.Predicates);
                preds.Add(predicate);
                eq._wherePredicate = new AndOrPredicate(Operator.And, preds);
            }
            else
            {
                eq._wherePredicate = new AndOrPredicate(Operator.And,
                                                        eq._wherePredicate, predicate);
            }
            return(eq);
        }
Beispiel #6
0
 public UnaryPredicate(Operator op, BasePredicate predicate) : base(op)
 {
     Predicate = predicate;
 }
 public AnyAllPredicate(Operator op, object exprSource, BasePredicate predicate) : base(op)
 {
     ExprSource = exprSource;
     Predicate  = predicate;
 }