private static IQueryable <T> ApplySort <T>(this IQueryable <T> query, Sorts <T> sorts)
 {
     if (!sorts.IsValid())
     {
         return(query);
     }
     return(Sorts <T> .ApplySorts(query, sorts));
 }
        private static IQueryable <T> ApplySort <T>(this IQueryable <T> query, Sorts <T> sorts)
        {
            if (!sorts.IsValid())
            {
                return(query);
            }
            var sort = sorts.Get();

            return(Sorts <T> .ApplySort(query, sort));
        }
Esempio n. 3
0
        internal static IQueryable <T> ApplySorts(IQueryable <T> query, Sorts <T> sorts)
        {
            var isFirstSort   = true;
            var validSortings = sorts.GetAll();
            IOrderedQueryable <T> orderedQuery = null;

            foreach (var sort in validSortings)
            {
                orderedQuery = isFirstSort
                    ? ApplySorting(query, sort)
                    : ApplySorting(orderedQuery, sort);
                isFirstSort = false;
            }

            return(orderedQuery ?? query);
        }
 /// <summary>
 /// Paginates your query and returns Page object for the given page number and page size.
 /// </summary>
 /// <typeparam name="T">Type of Entity for which pagination is being implemented.</typeparam>
 /// <param name="query">IQueryable on which pagination will be applied.</param>
 /// <param name="pageNumber">The page no. which needs to be fetched.</param>
 /// <param name="pageSize">The number or records expected in the page.</param>
 /// <param name="sorts">Conditional sorts.</param>
 /// <param name="filters">Conditional filters.</param>
 /// <returns>A Page object with filtered data for the given page number and page size.</returns>
 public static Page <T> Paginate <T>(this IQueryable <T> query, int pageNumber, int pageSize, Sorts <T> sorts, Filters <T> filters)
 {
     return(query.ApplyFilter(filters).Paginate(pageNumber, pageSize, sorts));
 }
 /// <summary>
 /// Paginates your query and returns Page object for the given page number and page size.
 /// </summary>
 /// <typeparam name="T">Type of Entity for which pagination is being implemented.</typeparam>
 /// <param name="query">IQueryable on which pagination will be applied.</param>
 /// <param name="pageNumber">The page no. which needs to be fetched.</param>
 /// <param name="pageSize">The number or records expected in the page.</param>
 /// <param name="sorts">Conditional sorts.</param>
 /// <returns>A Page object with filtered data for the given page number and page size.</returns>
 public static Page <T> Paginate <T>(this IQueryable <T> query, int pageNumber, int pageSize, Sorts <T> sorts)
 {
     return(query.ApplySort(sorts).Paginate(pageNumber, pageSize));
 }