private static IQueryable <T> ApplySort <T>(this IQueryable <T> query, Sorts <T> sorts) { if (!sorts.IsValid()) { return(query); } dynamic sort = sorts.Get(); var results = Sorts <T> .ApplySort(query, sort); return(results); }
internal IQueryable <T> ApplySort <TKey>(IQueryable <T> query, Sorts <T> sorts, Sort <T, TKey> sort) { IOrderedQueryable <T> nonFirstQuerable = null; var first = true; foreach (var c in Power()) { if (first) { nonFirstQuerable = ApplySortFisrt(query, c); first = false; } else { nonFirstQuerable = ApplySortNonFisrt(nonFirstQuerable, c); } } return(nonFirstQuerable); }
/// <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 async Task <Page <T> > PaginateAsync <T>(this IQueryable <T> query, int pageNumber, int pageSize, Sorts <T> sorts, Filters <T> filters) { var results = query.ApplyFilter(filters); return(await results.PaginateAsync(pageNumber, pageSize, sorts)); }
/// <summary> /// See `Task<Page<T>> PaginateAsync<T>(this IQueryable<T> query, int pageNumber, int pageSize, Sorts<T> sorts, Filters<T> filters)` /// </summary> public static Page <T> Paginate <T>(this IQueryable <T> query, int pageNumber, int pageSize, Sorts <T> sorts, Filters <T> filters) { var results = query.ApplyFilter(filters); return(results.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 async Task <Page <T> > PaginateAsync <T>(this IQueryable <T> query, int pageNumber, int pageSize, Sorts <T> sorts) { var result = query.ApplySort(sorts); return(await result.PaginateAsync(pageNumber, pageSize)); }
/// <summary> /// See `Task<Page<T>> PaginateAsync<T>(this IQueryable<T> query, int pageNumber, int pageSize, Sorts<T> sorts)` /// </summary> public static Page <T> Paginate <T>(this IQueryable <T> query, int pageNumber, int pageSize, Sorts <T> sorts) { var result = query.ApplySort(sorts); return(result.Paginate(pageNumber, pageSize)); }