コード例 #1
0
        /// <summary>
        /// orクエリの生成を行います。
        /// </summary>
        /// <param name="queries">or条件とするNCMBQueryをリストで指定</param>
        /// <returns> or条件を作成したクエリ</returns>
        public static NCMBQuery <T> Or(List <NCMBQuery <T> > queries)
        {
            List <NCMBQuery <T> > localList = new List <NCMBQuery <T> > ();      //queries内のクラス名取得
            string className = null;

            //nullのリストを渡された場合はExceptionを出す
            if (queries == null)
            {
                throw new NCMBException(new ArgumentException("queries may not be null."));
            }

            //空のリストを渡された場合はExceptionを出す
            if (queries.Count == 0)
            {
                throw new NCMBException(new ArgumentException("Can't take an or of an empty list of queries"));
            }

            //localListにqueriesの中の各クラス名を追加
            for (int i = 0; i < queries.Count; i++)
            {
                //違うクラス名同士のor結合は出来ない
                if ((className != null) && (!((NCMBQuery <T>)queries [i])._className.Equals(className)))
                {
                    throw new NCMBException(new ArgumentException("All of the queries in an or query must be on the same class "));
                }
                //渡されたリストの各NCMBQueryクラスのクラス名の取得
                className = ((NCMBQuery <T>)queries [i])._className;
                localList.Add((NCMBQuery <T>)queries [i]);
            }
            //Or条件の追加
            NCMBQuery <T> value = new NCMBQuery <T> (className);

            return(value._whereSatifiesAnyOf(localList));
        }