11using System ;
22using System . Collections . Generic ;
33using System . Linq ;
4- using System . Reflection ;
54
65namespace JsonApiDotNetCore . Internal
76{
87 public class ContextGraph : IContextGraph
98 {
10- public List < ContextEntity > Entities { get ; set ; }
11- public bool UsesDbContext { get ; set ; }
9+ private List < ContextEntity > _entities ;
10+
11+ public ContextGraph ( ) { }
12+
13+ public ContextGraph ( List < ContextEntity > entities , bool usesDbContext )
14+ {
15+ _entities = entities ;
16+ UsesDbContext = usesDbContext ;
17+ }
18+
19+ public bool UsesDbContext { get ; }
1220
1321 public ContextEntity GetContextEntity ( string entityName )
14- => Entities . SingleOrDefault ( e => string . Equals ( e . EntityName , entityName , StringComparison . OrdinalIgnoreCase ) ) ;
22+ => _entities . SingleOrDefault ( e => string . Equals ( e . EntityName , entityName , StringComparison . OrdinalIgnoreCase ) ) ;
1523
1624 public ContextEntity GetContextEntity ( Type entityType )
17- => Entities . SingleOrDefault ( e => e . EntityType == entityType ) ;
25+ => _entities . SingleOrDefault ( e => e . EntityType == entityType ) ;
1826
1927 public object GetRelationship < TParent > ( TParent entity , string relationshipName )
2028 {
@@ -33,7 +41,7 @@ public object GetRelationship<TParent>(TParent entity, string relationshipName)
3341 public string GetRelationshipName < TParent > ( string relationshipName )
3442 {
3543 var entityType = typeof ( TParent ) ;
36- return Entities
44+ return _entities
3745 . SingleOrDefault ( e => e . EntityType == entityType )
3846 ? . Relationships
3947 . SingleOrDefault ( r => string . Equals ( r . PublicRelationshipName , relationshipName , StringComparison . OrdinalIgnoreCase ) )
0 commit comments