@@ -66,7 +66,7 @@ public virtual async Task<IActionResult> GetAsync()
6666 entities = IncludeRelationships ( entities , _jsonApiContext . QuerySet . IncludedRelationships ) ;
6767
6868 if ( _jsonApiContext . Options . IncludeTotalRecordCount )
69- _jsonApiContext . TotalRecords = await entities . CountAsync ( ) ;
69+ _jsonApiContext . PageManager . TotalRecords = await entities . CountAsync ( ) ;
7070
7171 // pagination should be done last since it will execute the query
7272 var pagedEntities = await ApplyPageQueryAsync ( entities ) ;
@@ -188,17 +188,15 @@ private IQueryable<T> ApplySortAndFilterQuery(IQueryable<T> entities)
188188
189189 private async Task < IEnumerable < T > > ApplyPageQueryAsync ( IQueryable < T > entities )
190190 {
191- if ( _jsonApiContext . Options . DefaultPageSize == 0 && ( _jsonApiContext . QuerySet == null || _jsonApiContext . QuerySet . PageQuery . PageSize == 0 ) )
191+ var pageManager = _jsonApiContext . PageManager ;
192+ if ( ! pageManager . IsPaginated )
192193 return entities ;
193194
194195 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 ;
198196
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") ;
200198
201- return await _entities . PageAsync ( entities , pageSize , pageNumber ) ;
199+ return await _entities . PageAsync ( entities , pageManager . PageSize , pageManager . CurrentPage ) ;
202200 }
203201
204202 private IQueryable < T > IncludeRelationships ( IQueryable < T > entities , List < string > relationships )
0 commit comments