Ejemplo n.º 1
0
        /// <summary>
        /// Applies Dynamic OrderBy clauses from the given SortOptions
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="source">IQueryable</param>
        /// <param name="sortOptions">enumeration of SortOptions to apply to the given IQueryable</param>
        /// <returns></returns>
        public static IQueryable <T> AddSorting <T>(this IQueryable <T> source, string sort)
        {
            if (sort == null)
            {
                return(source);
            }

            var sortOptions = new SortOptionsParser().Parse(sort);

            return(AddSorting(source, sortOptions));
        }
        public FilterPageSortOptionsBuilder ParseSorting(IEnumerable <KeyValuePair <string, string> > querystring)
        {
            if (this.fps == null)
            {
                this.fps = new FilterPageSortOptions();
            }

            var sortqs = querystring.Where(_ => _.Key == "sort").FirstOrDefault();

            if (sortqs.Value != null)
            {
                var sortOptions = new SortOptionsParser().Parse(querystring.First(_ => _.Key == "sort").Value);
                fps.Sort = sortOptions;
            }
            else
            {
                fps.Sort = new SortOption[0];
            }

            return(this);
        }