@@ -66,7 +66,7 @@ public virtual async Task<IActionResult> GetAsync()
66
66
entities = IncludeRelationships ( entities , _jsonApiContext . QuerySet . IncludedRelationships ) ;
67
67
68
68
if ( _jsonApiContext . Options . IncludeTotalRecordCount )
69
- _jsonApiContext . TotalRecords = await entities . CountAsync ( ) ;
69
+ _jsonApiContext . PageManager . TotalRecords = await entities . CountAsync ( ) ;
70
70
71
71
// pagination should be done last since it will execute the query
72
72
var pagedEntities = await ApplyPageQueryAsync ( entities ) ;
@@ -188,17 +188,15 @@ private IQueryable<T> ApplySortAndFilterQuery(IQueryable<T> entities)
188
188
189
189
private async Task < IEnumerable < T > > ApplyPageQueryAsync ( IQueryable < T > entities )
190
190
{
191
- if ( _jsonApiContext . Options . DefaultPageSize == 0 && ( _jsonApiContext . QuerySet == null || _jsonApiContext . QuerySet . PageQuery . PageSize == 0 ) )
191
+ var pageManager = _jsonApiContext . PageManager ;
192
+ if ( ! pageManager . IsPaginated )
192
193
return entities ;
193
194
194
195
var query = _jsonApiContext . QuerySet ? . PageQuery ?? new PageQuery ( ) ;
195
-
196
- var pageNumber = query . PageOffset > 0 ? query . PageOffset : 1 ;
197
- var pageSize = query . PageSize > 0 ? query . PageSize : _jsonApiContext . Options . DefaultPageSize ;
198
196
199
- _logger ? . LogInformation ( $ "Applying paging query. Fetching page { pageNumber } with { pageSize } entities") ;
197
+ _logger ? . LogInformation ( $ "Applying paging query. Fetching page { pageManager . CurrentPage } with { pageManager . PageSize } entities") ;
200
198
201
- return await _entities . PageAsync ( entities , pageSize , pageNumber ) ;
199
+ return await _entities . PageAsync ( entities , pageManager . PageSize , pageManager . CurrentPage ) ;
202
200
}
203
201
204
202
private IQueryable < T > IncludeRelationships ( IQueryable < T > entities , List < string > relationships )
0 commit comments