public PaginatedQuery(IQueryable <T> query, int offset, int limit) { var itemCount = query.Count(); double pageSize = limit; Pagination = new PaginationMetadata() { CurrentPage = (int)Math.Floor(offset / pageSize) + 1, PageSize = limit, TotalCount = itemCount, TotalPages = (int)Math.Ceiling(itemCount / pageSize) }; Query = query.Skip(offset).Take(limit); }
public PaginatedList(IEnumerable <T> items, int offset, int limit) { var itemCount = items.Count(); double pageSize = limit; Pagination = new PaginationMetadata() { CurrentPage = (int)Math.Floor(offset / pageSize) + 1, PageSize = limit, TotalCount = itemCount, TotalPages = (int)Math.Ceiling(itemCount / pageSize) }; Items = items.Skip(offset) .Take(limit) .ToArray(); }
public PaginatedList(IEnumerable <T> items, PaginationMetadata pagination) { Pagination = pagination; Items = items; }