예제 #1
0
파일: SqlQuery.cs 프로젝트: vebin/IQMap
        /// <summary>
        /// Adds an item to the sorting list. If it exists already, it will be superceded (deprioritized), unless the existing
        /// item is marked as "Required" or "RequiredOrder." In the first case, only the order (asc or desc) will be changed to
        /// the current value. In the 2nd case, no changes will be made.
        /// </summary>
        /// <param name="field"></param>
        /// <param name="order"></param>
        /// <param name="priority"></param>
        /// <returns></returns>
        public ISqlQuery AddSort(string field, SortOrder order, SortPriority priority)
        {
            if (String.IsNullOrEmpty(field))
            {
                throw new Exception("The field name cannot be missing to add a sort");
            }
            string sortOrder      = order == SortOrder.Ascending ? "" : " DESC";
            int    index          = sortCriterionList.Count - 1;
            string fieldNameClean = unAliased(field.Trim().ToLower());

            bool found = false;

            while (index >= 0)
            {
                var item = sortCriterionList[index];
                if (item.Field == fieldNameClean)
                {
                    switch (item.Priority)
                    {
                    case SortPriority.RequiredOrder:
                        found = true;
                        index = -1;
                        break;

                    case SortPriority.Required:
                        sortCriterionList[index]       = new SortCriterion(fieldNameClean, order, item.Priority);
                        sortCriterionList[index].Owner = this;
                        index = -1;
                        found = true;
                        break;

                    default:
                        sortCriterionList.RemoveAt(index);
                        break;
                    }
                }

                index--;
            }
            if (!found)
            {
                var crit = new SortCriterion(fieldNameClean, order, priority);
                crit.Owner = this;
                sortCriterionList.Add(crit);
                Touch();
            }

            return(this);
        }
예제 #2
0
        public SortCriterion Clone()
        {
            SortCriterion clone = new SortCriterion(Field, Order, Priority);

            return(clone);
        }
예제 #3
0
파일: SqlQuery.cs 프로젝트: saneman1/IQMap
        /// <summary>
        /// Adds an item to the sorting list. If it exists already, it will be superceded (deprioritized), unless the existing
        /// item is marked as "Required" or "RequiredOrder." In the first case, only the order (asc or desc) will be changed to
        /// the current value. In the 2nd case, no changes will be made.
        /// </summary>
        /// <param name="field"></param>
        /// <param name="order"></param>
        /// <param name="priority"></param>
        /// <returns></returns>
        public ISqlQuery AddSort(string field, SortOrder order, SortPriority priority)
        {
            if (String.IsNullOrEmpty(field))
            {
                throw new Exception("The field name cannot be missing to add a sort");
            }
            string sortOrder = order == SortOrder.Ascending ? "" : " DESC";
            int index = sortCriterionList.Count - 1;
            string fieldNameClean = unAliased(field.Trim().ToLower());

            bool found = false;
            while (index >= 0)
            {
                var item = sortCriterionList[index];
                if (item.Field == fieldNameClean)
                {
                    switch (item.Priority)
                    {
                        case SortPriority.RequiredOrder:
                            found = true;
                            index = -1;
                            break;
                        case SortPriority.Required:
                            sortCriterionList[index] = new SortCriterion(fieldNameClean, order, item.Priority);
                            sortCriterionList[index].Owner = this;
                            index = -1;
                            found = true;
                            break;
                        default:
                            sortCriterionList.RemoveAt(index);
                            break;
                    }
                }

                index--;
            }
            if (!found)
            {
                var crit = new SortCriterion(fieldNameClean, order, priority);
                crit.Owner = this;
                sortCriterionList.Add(crit);
                Touch();
            }

            return this;
        }
예제 #4
0
 public SortCriterion Clone()
 {
     SortCriterion clone = new SortCriterion(Field,Order,Priority);
     return clone;
 }