Пример #1
0
        public static async Task <PagedList <T> > ToPagedListAsync <T>(this IQueryable <T> query, Pageable pageable)
        {
            var count = await query?.CountAsync();

            var queryResult = await query?
                              .Paged(pageable)?
                              .ToListAsync();

            return(new PagedList <T>(queryResult, count, pageable));
        }
Пример #2
0
 public static IQueryable <TSource> Paged <TSource>(this IQueryable <TSource> source, Pageable query)
 {
     return(source
            .Skip(query.SkipCount)
            .Take(query.PageSize));
 }
Пример #3
0
        private static PagedList <TDestination> GetPagedList <TSource, TDestination>(IQueryable <TSource> query, Pageable pageable, IMapper mapper, Action <IMappingOperationOptions> opts = null)
        {
            var count = query?.Count() ?? 0;

            var queryResult = query?
                              .Paged(pageable)?
                              .ToList();

            List <TDestination> items;

            if (opts == null)
            {
                items = mapper.Map <List <TDestination> >(queryResult);
            }
            else
            {
                items = mapper.Map <List <TDestination> >(queryResult, opts);
            }

            return(new PagedList <TDestination>(items, count, pageable));
        }
Пример #4
0
 public static PagedList <TDestination> ToPagedList <TSource, TDestination>(this IQueryable <TSource> query, Pageable pageable, IMapper mapper, Action <IMappingOperationOptions> opts)
 {
     return(GetPagedList <TSource, TDestination>(query, pageable, mapper, opts));
 }
Пример #5
0
 public static PagedList <TDestination> ToPagedList <TSource, TDestination>(this IQueryable <TSource> query, Pageable pageable, IMapper mapper)
 {
     return(GetPagedList <TSource, TDestination>(query, pageable, mapper));
 }
Пример #6
0
 public static async Task <PagedList <TDestination> > ToPagedListAsync <TSource, TDestination>(this IQueryable <TSource> query, Pageable pageable, IMapper mapper)
 {
     return(await GetPagedListAsync <TSource, TDestination>(query, pageable, mapper));
 }