Пример #1
0
        public List <T> GenericSort <T>(IQueryable <T> query, SortingModel Model)
        {
            var result = new List <T>();

            if (Model.SortingColumnNew.IsEmpty())
            {
                return(query.ToList());
            }

            Expression <Func <T, object> > orderByExp = ExpBuilder.CreatePropertyExpression <T, object>(Model.SortingColumnNew.Trim());
            bool OrderByDescending = CalculateSortingOrder(Model);

            if (OrderByDescending)
            {
                result = query.OrderByDescending(orderByExp).ToList();
            }
            else
            {
                result = query.OrderBy(orderByExp).ToList();
            }
            Model.ShouldReOrder = false;
            return(result);
        }