public static IQueryable <T> ApplyOrdering <T>(this IQueryable <T> query, IQueryObject queryObj, Dictionary <string, Expression <Func <T, object> > > columnsMap)
        {
            if (String.IsNullOrWhiteSpace(queryObj.Sort) || !columnsMap.ContainsKey(queryObj.Sort))
            {
                return(query);
            }

            if (queryObj.SortDir == ASC)
            {
                return(query.OrderBy(columnsMap[queryObj.Sort]));
            }
            else
            {
                return(query.OrderByDescending(columnsMap[queryObj.Sort]));
            }
        }
예제 #2
0
        public static IQueryable <T> ApplyPaging <T>(this IQueryable <T> query, IQueryObject filter)
        {
            query = query.Skip((filter.Page - 1) * filter.PageSize).Take(filter.PageSize);

            return(query);
        }