/// <summary> /// Gets the paged results by applying the requested paging parameters. You must have applied your sort before calling this method. /// </summary> /// <param name="pagingOptions"></param> /// <param name="queryable"></param> public static PagedResults <T> GetPagedResults <T>(PagingOptions pagingOptions, IQueryable <T> queryable) { var results = new PagedResults <T>() { PagingOptions = pagingOptions }; int totalCount = queryable.Count(); results.Count = totalCount; results.PageCount = (totalCount / pagingOptions.PageSize) + ((totalCount % pagingOptions.PageSize == 0) ? 0 : 1); results.Items = queryable.Skip(pagingOptions.RecordsToSkip()).Take(pagingOptions.PageSize).ToList(); return(results); }