Exemple #1
0
        private Page <TResult> GetPageInternal <TSource, TResult>(IQueryable <TSource> items, PagingOptions options, Expression <Func <TSource, TResult> > selector)
            where TSource : class
            where TResult : class
        {
            var filtered = Filter(items, options);
            var sorted   = Sort(filtered, options.SortSetting);

            var elements = sorted
                           .GetPage(options.PageNumber, options.PageSize)
                           .Select(selector)
                           .ToList();

            return(new Page <TResult>()
            {
                Items = elements,
                PageNumber = options.PageNumber,
                PageSize = options.PageSize,
                Total = filtered.Count(),
            });
        }
Exemple #2
0
 public static async Task <Page <TResult> > GetPageAsync <TSource, TResult>(IQueryable <TSource> items, PagingOptions options, Expression <Func <TSource, TResult> > selector)
     where TSource : class
     where TResult : class
 {
     return(await new Pager()
            .GetPageInternalAsync(items, options, selector));
 }
Exemple #3
0
 public static Page <TResult> GetPage <TSource, TResult>(IEnumerable <TSource> items, PagingOptions options, Expression <Func <TSource, TResult> > selector)
     where TSource : class
     where TResult : class
 {
     return(new Pager()
            .GetPageInternal(items.AsQueryable(), options, selector));
 }
Exemple #4
0
 public static async Task <Page <T> > GetPageAsync <T>(IQueryable <T> items, PagingOptions options)
     where T : class
 {
     return(await GetPageAsync(items, options, i => i));
 }
Exemple #5
0
 public static Page <T> GetPage <T>(IEnumerable <T> items, PagingOptions options)
     where T : class
 {
     return(GetPage(items, options, i => i));
 }