public ValuesService(IUnitOfWork unitOfWork)
 {
     _unitOfWork           = unitOfWork;
     _valuesRepo           = _unitOfWork.GetRepository <ValueRecord>();
     _changeLogRepo        = _unitOfWork.GetRepository <ChangeLogRecord>();
     _changeLogValueRepo   = _unitOfWork.GetRepository <ChangeLogValueRecord>();
     _currentSortDirection = new CurrentSortDirection(_unitOfWork);
 }
Пример #2
0
        private DetachedCriteria AddSortingField(string currentSortingExpression,
                                                 SortDirection currentSortDirection)
        {
            if (!AllowMultiColumnSorting)
            {
                //todo 清空排序字段
                SortingFields = new List <IDictionary <string, string> >();
            }

            SortExpression = currentSortingExpression;
            if (CurrentSortDirection == SortDirection.Ascending)
            {
                currentSortDirection = SortDirection.Ascending;
                CurrentSortDirection = SortDirection.Descending;
            }
            else
            {
                currentSortDirection = SortDirection.Descending;
                CurrentSortDirection = SortDirection.Ascending;
            }

            IList <IDictionary <string, string> > newSortingFields = new List <IDictionary <string, string> >();

            for (int i = SortingFields.Count - 3; i < SortingFields.Count; i++)
            {
                if (i < 0)
                {
                    continue;
                }
                IDictionary <string, string> field = SortingFields[i];

                //用户指定排序字段和之前旧的排序字段重复的话,旧的排序字段不添加到排序列中
                if (!field.ContainsKey(SortExpression))
                {
                    newSortingFields.Add(field);
                }
            }
            IDictionary <string, string> newField = new Dictionary <string, string>();

            newField.Add(SortExpression, CurrentSortDirection.ToString());
            newSortingFields.Add(newField);
            SortingFields = newSortingFields;
            if (newSortingFields.Count > 3)
            {
                newSortingFields.RemoveAt(0);
            }

            return(this.AddSortingField());
        }