public class PagedList : List { public int current_page { get; set; } public int total_pages { get; set; } public int page_size { get; set; } public int total_count { get; set; } public bool has_previous => current_page > 1; public bool has_next => current_page < total_pages; public PagedList() { } public PagedList(List items, int count, int page_number, int page_size) { total_count = count; this.page_size = page_size; current_page = page_number; total_pages = (int)Math.Ceiling(count / (double)page_size); AddRange(items); } public static async Task> ToPagedListAsync(IQueryable source, int page_number, int page_size) { var count = source.Count(); var items = await source.Skip((page_number - 1) * page_size).Take(page_size).ToListAsync(); return new PagedList(items, count, page_number, page_size); } }