Ejemplo n.º 1
0
        /// <summary>
        ///  for ef query
        /// </summary>
        public static async Task <IPagedList <T> > ToPagedListAsync <T>(this IQueryable <T> source, IQueryOffsetInput model, CancellationToken cancellationToken = default)
        {
            var count = await source.CountAsync();

            var list = await source.Skip(model.Skip).Take(model.Limit).ToListAsync(cancellationToken);

            var result = new PagedList <T>();

            result.LoadSource(list, model.GetPageNumber(), model.Limit, count);
            return(result);
        }
Ejemplo n.º 2
0
 public static int GetPageNumber(this IQueryOffsetInput model)
 {
     return(model.Skip / model.Limit + 1);
 }