Esempio n. 1
0
        } // end method



        private IEnumerable<T> CreateObjects<T>(IEnumerable<IRecord> records,
            CursorData cursorData) where T : new() {
            var objs = new List<T>();
            foreach (var record in records)
                objs.Add(CreateObject<T>(record));
            return objs;
        } // end method
Esempio n. 2
0
        } // end method



        internal IEnumerable<CursorData> SplitLargeCollections(int maxParameters) {
            var cursorDatas = new List<CursorData>();

            if (criteria != null)
                foreach (var criterion in criteria)
                    criterion.Distinctify();

            var largest = GetLargestCollectionCriterion(ref maxParameters);
            if (largest == null)
                cursorDatas.Add(this);
            else {
                // Get the vals from the largest collection and then set the Value to null.
                // Value is set to null to allow it to be null when the criterion is cloned
                // and is reset its intial value after the split is done.
                var vals = largest.GetValues();
                largest.Value = null;

                CursorData clone = null;
                Criterion replacementCriterion = null;
                List<object> replacementVals = null;
                foreach (var val in vals) {
                    // If clone is null, which would be either the first iteration or one
                    // following a break, clone the current CursorData, get a reference to
                    // the criterion matching the largest criterion (replacementCriterion)
                    // and set its value to a new list.
                    if (clone == null) {
                        clone = Clone();
                        replacementCriterion = clone.criteria.First(c =>
                            c.Name == largest.Name &&
                            c.Operation == largest.Operation &&
                            c.Value == null);
                        replacementVals = new List<object>();
                        replacementCriterion.Value = replacementVals;
                    } // end if

                    replacementVals.Add(val);

                    // Iteration break: when replacementVals is at the max, add the clone
                    // to cursorDatas and set it to null.  If there are move values to add,
                    // the next iteration will create a new clone.
                    if (replacementVals.Count == maxParameters) {
                        cursorDatas.Add(clone);
                        clone = null;
                    } // end if
                } // end foreach

                // If there is clone (and there probably is) add it to cursorDatas.
                if (clone != null)
                    cursorDatas.Add(clone);

                largest.Value = vals; // Reset Value to its original, er... value.
            } // end if-else

            return cursorDatas;
        } // end method
Esempio n. 3
0
        public CursorData Clone() {
            var newCursorData = new CursorData();

            if (criteria != null) {
                var newCriteria = new List<Criterion>();
                foreach (var criterion in criteria)
                    newCriteria.Add(criterion.Clone());
                newCursorData.criteria = newCriteria;
            } // end if

            newCursorData.limit = limit;
            newCursorData.skip = skip;

            if (sort != null) {
                var newSort = new Dictionary<string, int>();
                foreach (var key in sort.Keys)
                    newSort[key] = sort[key];
                newCursorData.sort = newSort;
            } // end if

            return newCursorData;
        } // end method
Esempio n. 4
0
 public abstract IEnumerable <IRecord> Fetch(IEnumerable <string> tableNames, CursorData cursorData);