Esempio n. 1
0
        /// <summary>
        /// Возвращает информацию о сортировке
        /// </summary>
        /// <param name="sortParameter">параметр сортировки</param>
        /// <returns>информация о сортировке</returns>
        private static SortingInformation GetSortingInformation(string sortParameter)
        {
            SortingInformation sortInfo = null;
            var processedSortParameter = Converter.ToString(sortParameter).Trim();

            if (processedSortParameter.Length > 0)
            {
                string fieldName;
                var direction = SortDirection.Ascending;

                if (SqlDirectionRegExp.IsMatch(processedSortParameter))
                {
                    fieldName = RemoveSortDirection(processedSortParameter);
                    if (SqlDescendingDirectionRegExp.IsMatch(processedSortParameter))
                    {
                        direction = SortDirection.Descending;
                    }
                }
                else
                {
                    fieldName = processedSortParameter;
                }
                fieldName = RemoveSquareBrackets(fieldName);

                sortInfo = new SortingInformation(fieldName, direction);
            }

            return sortInfo;
        }
Esempio n. 2
0
        /// <summary>
        /// Возвращает информацию о сортировке
        /// </summary>
        /// <param name="sortParameter">параметр сортировки</param>
        /// <returns>информация о сортировке</returns>
        private static SortingInformation GetSortingInformation(string sortParameter, DatabaseType dbType = DatabaseType.SqlServer)
        {
            SortingInformation sortInfo = null;
            var processedSortParameter  = Converter.ToString(sortParameter).Trim();

            if (processedSortParameter.Length > 0)
            {
                string fieldName;
                var    direction = SortDirection.Ascending;

                if (SqlDirectionRegExp.IsMatch(processedSortParameter))
                {
                    fieldName = RemoveSortDirection(processedSortParameter);
                    if (SqlDescendingDirectionRegExp.IsMatch(processedSortParameter))
                    {
                        direction = SortDirection.Descending;
                    }
                }
                else
                {
                    fieldName = processedSortParameter;
                }
                fieldName = RemoveEscapeSymbols(fieldName, dbType);

                sortInfo = new SortingInformation(fieldName, direction);
            }

            return(sortInfo);
        }