4
4
using JsonApiDotNetCore . Data ;
5
5
using JsonApiDotNetCore . Extensions ;
6
6
using JsonApiDotNetCore . Internal ;
7
- using JsonApiDotNetCore . Internal . Query ;
8
7
using JsonApiDotNetCore . Models ;
9
8
using Microsoft . EntityFrameworkCore ;
10
9
using Microsoft . Extensions . Logging ;
@@ -47,7 +46,7 @@ public virtual async Task<IEnumerable<T>> GetAsync()
47
46
48
47
entities = ApplySortAndFilterQuery ( entities ) ;
49
48
50
- if ( _jsonApiContext . QuerySet ? . IncludedRelationships != null && _jsonApiContext . QuerySet . IncludedRelationships . Count > 0 )
49
+ if ( ShouldIncludeRelationships ( ) )
51
50
entities = IncludeRelationships ( entities , _jsonApiContext . QuerySet . IncludedRelationships ) ;
52
51
53
52
if ( _jsonApiContext . Options . IncludeTotalRecordCount )
@@ -61,13 +60,16 @@ public virtual async Task<IEnumerable<T>> GetAsync()
61
60
public virtual async Task < T > GetAsync ( TId id )
62
61
{
63
62
T entity ;
64
- if ( _jsonApiContext . QuerySet ? . IncludedRelationships != null )
63
+ if ( ShouldIncludeRelationships ( ) )
65
64
entity = await GetWithRelationshipsAsync ( id ) ;
66
65
else
67
66
entity = await _entities . GetAsync ( id ) ;
68
67
return entity ;
69
68
}
70
69
70
+ private bool ShouldIncludeRelationships ( )
71
+ => ( _jsonApiContext . QuerySet ? . IncludedRelationships != null && _jsonApiContext . QuerySet . IncludedRelationships . Count > 0 ) ;
72
+
71
73
private async Task < T > GetWithRelationshipsAsync ( TId id )
72
74
{
73
75
var query = _entities . Get ( ) ;
0 commit comments