44using JsonApiDotNetCore . Data ;
55using JsonApiDotNetCore . Extensions ;
66using JsonApiDotNetCore . Internal ;
7- using JsonApiDotNetCore . Internal . Query ;
87using JsonApiDotNetCore . Models ;
98using Microsoft . EntityFrameworkCore ;
109using Microsoft . Extensions . Logging ;
@@ -47,7 +46,7 @@ public virtual async Task<IEnumerable<T>> GetAsync()
4746
4847 entities = ApplySortAndFilterQuery ( entities ) ;
4948
50- if ( _jsonApiContext . QuerySet ? . IncludedRelationships != null && _jsonApiContext . QuerySet . IncludedRelationships . Count > 0 )
49+ if ( ShouldIncludeRelationships ( ) )
5150 entities = IncludeRelationships ( entities , _jsonApiContext . QuerySet . IncludedRelationships ) ;
5251
5352 if ( _jsonApiContext . Options . IncludeTotalRecordCount )
@@ -61,13 +60,16 @@ public virtual async Task<IEnumerable<T>> GetAsync()
6160 public virtual async Task < T > GetAsync ( TId id )
6261 {
6362 T entity ;
64- if ( _jsonApiContext . QuerySet ? . IncludedRelationships != null )
63+ if ( ShouldIncludeRelationships ( ) )
6564 entity = await GetWithRelationshipsAsync ( id ) ;
6665 else
6766 entity = await _entities . GetAsync ( id ) ;
6867 return entity ;
6968 }
7069
70+ private bool ShouldIncludeRelationships ( )
71+ => ( _jsonApiContext . QuerySet ? . IncludedRelationships != null && _jsonApiContext . QuerySet . IncludedRelationships . Count > 0 ) ;
72+
7173 private async Task < T > GetWithRelationshipsAsync ( TId id )
7274 {
7375 var query = _entities . Get ( ) ;
0 commit comments