@@ -6,10 +6,45 @@ namespace JsonApiDotNetCore.Internal
6
6
{
7
7
public interface IContextGraph
8
8
{
9
- object GetRelationship < TParent > ( TParent entity , string relationshipName ) ;
9
+ /// <summary>
10
+ /// Gets the value of the navigation property, defined by the relationshipName,
11
+ /// on the provided instance.
12
+ /// </summary>
13
+ /// <param name="resource">The resource instance</param>
14
+ /// <param name="propertyName">The navigation property name.</param>
15
+ /// <example>
16
+ /// <code>
17
+ /// _graph.GetRelationship(todoItem, nameof(TodoItem.Owner));
18
+ /// </code>
19
+ /// </example>
20
+ object GetRelationship < TParent > ( TParent resource , string propertyName ) ;
21
+
22
+ /// <summary>
23
+ /// Get the internal navigation property name for the specified public
24
+ /// relationship name.
25
+ /// </summary>
26
+ /// <param name="relationshipName">The public relationship name specified by a <see cref="HasOneAttribute" /> or <see cref="HasManyAttribute" /></param>
27
+ /// <example>
28
+ /// <code>
29
+ /// _graph.GetRelationshipName<TodoItem>("achieved-date");
30
+ /// // returns "AchievedDate"
31
+ /// </code>
32
+ /// </example>
10
33
string GetRelationshipName < TParent > ( string relationshipName ) ;
34
+
35
+ /// <summary>
36
+ /// Get the resource metadata by the DbSet property name
37
+ /// </summary>
11
38
ContextEntity GetContextEntity ( string dbSetName ) ;
39
+
40
+ /// <summary>
41
+ /// Get the resource metadata by the resource type
42
+ /// </summary>
12
43
ContextEntity GetContextEntity ( Type entityType ) ;
44
+
45
+ /// <summary>
46
+ /// Was built against an EntityFrameworkCore DbContext ?
47
+ /// </summary>
13
48
bool UsesDbContext { get ; }
14
49
}
15
50
@@ -40,14 +75,18 @@ internal ContextGraph(List<ContextEntity> entities, bool usesDbContext, List<Val
40
75
Instance = this ;
41
76
}
42
77
78
+ /// </ inheritdoc>
43
79
public bool UsesDbContext { get ; }
44
80
81
+ /// </ inheritdoc>
45
82
public ContextEntity GetContextEntity ( string entityName )
46
83
=> Entities . SingleOrDefault ( e => string . Equals ( e . EntityName , entityName , StringComparison . OrdinalIgnoreCase ) ) ;
47
84
85
+ /// </ inheritdoc>
48
86
public ContextEntity GetContextEntity ( Type entityType )
49
87
=> Entities . SingleOrDefault ( e => e . EntityType == entityType ) ;
50
88
89
+ /// </ inheritdoc>
51
90
public object GetRelationship < TParent > ( TParent entity , string relationshipName )
52
91
{
53
92
var parentEntityType = entity . GetType ( ) ;
@@ -62,6 +101,7 @@ public object GetRelationship<TParent>(TParent entity, string relationshipName)
62
101
return navigationProperty . GetValue ( entity ) ;
63
102
}
64
103
104
+ /// </ inheritdoc>
65
105
public string GetRelationshipName < TParent > ( string relationshipName )
66
106
{
67
107
var entityType = typeof ( TParent ) ;
0 commit comments