Esempio n. 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));
        }
Esempio n. 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");
        }