コード例 #1
0
ファイル: IAVQuery.cs プロジェクト: longyunzhou/NFC
 internal abstract S CreateInstance(AVQueryBase <S, T> source,
                                    IDictionary <string, object> where      = null,
                                    IEnumerable <string> replacementOrderBy = null,
                                    IEnumerable <string> thenBy             = null,
                                    int?skip  = null,
                                    int?limit = null,
                                    IEnumerable <string> includes     = null,
                                    IEnumerable <string> selectedKeys = null,
                                    String redirectClassNameForKey    = null);
コード例 #2
0
ファイル: AVQuery.cs プロジェクト: longyunzhou/NFC
 internal override AVQuery <T> CreateInstance(
     AVQueryBase <AVQuery <T>, T> source,
     IDictionary <string, object> where      = null,
     IEnumerable <string> replacementOrderBy = null,
     IEnumerable <string> thenBy             = null,
     int?skip  = null,
     int?limit = null,
     IEnumerable <string> includes     = null,
     IEnumerable <string> selectedKeys = null,
     String redirectClassNameForKey    = null)
 {
     return(new AVQuery <T>(this, where, replacementOrderBy, thenBy, skip, limit, includes, selectedKeys, redirectClassNameForKey));
 }
コード例 #3
0
ファイル: IAVQuery.cs プロジェクト: longyunzhou/NFC
        //public abstract Task<IEnumerable<T>> FindAsync();
        //public abstract Task<int> CountAsync();
        //public abstract Task<T> GetAsync(string objectId);
        //public abstract Task<T> FirstOrDefaultAsync();

        /// <summary>
        /// Private constructor for composition of queries. A Source query is required,
        /// but the remaining values can be null if they won't be changed in this
        /// composition.
        /// </summary>
        protected AVQueryBase(AVQueryBase <S, T> source,
                              IDictionary <string, object> where      = null,
                              IEnumerable <string> replacementOrderBy = null,
                              IEnumerable <string> thenBy             = null,
                              int?skip  = null,
                              int?limit = null,
                              IEnumerable <string> includes     = null,
                              IEnumerable <string> selectedKeys = null,
                              String redirectClassNameForKey    = null)
        {
            if (source == null)
            {
                throw new ArgumentNullException("Source");
            }

            className                    = source.className;
            this.where                   = source.where;
            this.orderBy                 = source.orderBy;
            this.skip                    = source.skip;
            this.limit                   = source.limit;
            this.includes                = source.includes;
            this.selectedKeys            = source.selectedKeys;
            this.redirectClassNameForKey = source.redirectClassNameForKey;

            if (where != null)
            {
                var newWhere = MergeWhereClauses(where);
                this.where = new Dictionary <string, object>(newWhere);
            }

            if (replacementOrderBy != null)
            {
                this.orderBy = new ReadOnlyCollection <string>(replacementOrderBy.ToList());
            }

            if (thenBy != null)
            {
                if (this.orderBy == null)
                {
                    throw new ArgumentException("You must call OrderBy before calling ThenBy.");
                }
                var newOrderBy = new List <string>(this.orderBy);
                newOrderBy.AddRange(thenBy);
                this.orderBy = new ReadOnlyCollection <string>(newOrderBy);
            }

            // Remove duplicates.
            if (this.orderBy != null)
            {
                var newOrderBy = new HashSet <string>(this.orderBy);
                this.orderBy = new ReadOnlyCollection <string>(newOrderBy.ToList <string>());
            }

            if (skip != null)
            {
                this.skip = (this.skip ?? 0) + skip;
            }

            if (limit != null)
            {
                this.limit = limit;
            }

            if (includes != null)
            {
                var newIncludes = MergeIncludes(includes);
                this.includes = new ReadOnlyCollection <string>(newIncludes.ToList());
            }

            if (selectedKeys != null)
            {
                var newSelectedKeys = MergeSelectedKeys(selectedKeys);
                this.selectedKeys = new ReadOnlyCollection <string>(newSelectedKeys.ToList());
            }

            if (redirectClassNameForKey != null)
            {
                this.redirectClassNameForKey = redirectClassNameForKey;
            }
        }