Esempio n. 1
0
        /// <summary>
        /// _whereに検索条件($neなど)の追加。
        /// </summary>
        private void _addCondition(string key, string condition, object value)
        {
            Dictionary <string, object> whereValue = null;

            value = NCMBUtility._maybeEncodeJSONObject(value, true);
            if (_where.ContainsKey(key))
            {
                //キーの前回条件がWhereEqualToだった場合はint型 それ以外はDictionary型が入る
                object existingValue = _where [key];
                if (existingValue is IDictionary)
                {
                    whereValue = (Dictionary <string, object>)existingValue;
                }
            }
            //初回またはキーの前回条件がWhereEqualToだった場合
            if (whereValue == null)
            {
                whereValue = new Dictionary <string, object> ();
            }
            whereValue [condition] = value;
            this._where [key]      = whereValue;
            NCMBDebug.Log("【_addCondition】where : " + Json.Serialize(this._where));
        }
Esempio n. 2
0
        /// <summary>
        /// URLに結合する(where以降)データの作成。<br/>
        /// URLと結合するときにJSON化を行う。
        /// </summary>
        private Dictionary <string, object> _getFindParams()
        {
            Dictionary <string, object> beforeJsonData = new Dictionary <string, object> ();
            Dictionary <string, object> whereData      = new Dictionary <string, object> ();

            beforeJsonData ["className"] = this._className;

            //$or検索も出来るようにする
            foreach (string key in this._where.Keys)
            {
                if (key.Equals("$or"))
                {
                    List <NCMBQuery <T> > queries = (List <NCMBQuery <T> >) this._where [key];

                    List <object> array = new List <object> ();
                    foreach (NCMBQuery <T> query in queries)
                    {
                        if (query._limit >= 0)
                        {
                            throw new ArgumentException("Cannot have limits in sub queries of an 'OR' query");
                        }
                        if (query._skip > 0)
                        {
                            throw new ArgumentException("Cannot have skips in sub queries of an 'OR' query");
                        }
                        if (query._order.Count > 0)
                        {
                            throw new ArgumentException("Cannot have an order in sub queries of an 'OR' query");
                        }
                        if (query._include.Count > 0)
                        {
                            throw new ArgumentException("Cannot have an include in sub queries of an 'OR' query");
                        }
                        Dictionary <string, object> dic = query._getFindParams();
                        if (dic ["where"] != null)
                        {
                            //where=有
                            array.Add(dic ["where"]);
                        }
                        else
                        {
                            //where=無
                            array.Add(new Dictionary <string, object> ());
                        }
                    }
                    whereData [key] = array;
                }
                else
                {
                    object value = _encodeSubQueries(this._where [key]);
                    whereData [key] = NCMBUtility._maybeEncodeJSONObject(value, true);                     //※valueの値に注意
                }
            }
            beforeJsonData ["where"] = whereData;
            //各オプション毎の設定

            if (this._limit >= 0)
            {
                beforeJsonData ["limit"] = this._limit;
            }

            if (this._skip > 0)
            {
                beforeJsonData ["skip"] = this._skip;
            }

            if (this._order.Count > 0)
            {
                beforeJsonData ["order"] = _join(this._order, ",");
            }

            if (this._include.Count > 0)
            {
                beforeJsonData ["include"] = _join(this._include, ",");
            }

            NCMBDebug.Log("【_getFindParams】beforeJsonData : " + Json.Serialize(beforeJsonData));
            return(beforeJsonData);
        }
Esempio n. 3
0
 /// <summary>
 /// 一致する。
 /// </summary>
 /// <param name="key"> 条件指定するフィールド名</param>
 /// <param name="value">  値</param>
 /// <returns> クエリ</returns>
 public NCMBQuery <T> WhereEqualTo(string key, object value)
 {
     value        = NCMBUtility._maybeEncodeJSONObject(value, true);
     _where [key] = value;
     return(this);
 }
Esempio n. 4
0
 internal NCMBQuery <T> _whereRelatedTo(NCMBObject parent, String key)
 {
     this._addCondition("$relatedTo", "object", NCMBUtility._maybeEncodeJSONObject(parent, true));
     this._addCondition("$relatedTo", "key", key);
     return(this);
 }
Esempio n. 5
0
 public object Encode()
 {
     //エンコードを行う
     return(NCMBUtility._maybeEncodeJSONObject(this.Value, true));
 }