@@ -117,25 +117,24 @@ public virtual async Task<object> GetRelationshipsAsync(TId id, string relations
117
117
118
118
public virtual async Task < object > GetRelationshipAsync ( TId id , string relationshipName )
119
119
{
120
- // compound-property -> CompoundProperty
121
- var navigationPropertyName = _jsonApiContext . ContextGraph . GetRelationshipName < TResource > ( relationshipName ) ;
122
- if ( navigationPropertyName == null )
123
- throw new JsonApiException ( 422 , $ "Relationship '{ relationshipName } ' does not exist on resource '{ typeof ( TResource ) } '.") ;
124
-
125
- var entity = await _entities . GetAndIncludeAsync ( id , navigationPropertyName ) ;
120
+ var entity = await _entities . GetAndIncludeAsync ( id , relationshipName ) ;
126
121
127
122
// TODO: it would be better if we could distinguish whether or not the relationship was not found,
128
123
// vs the relationship not being set on the instance of T
129
124
if ( entity == null )
130
125
{
131
- throw new JsonApiException ( 404 , $ "Relationship '{ navigationPropertyName } ' not found.") ;
126
+ throw new JsonApiException ( 404 , $ "Relationship '{ relationshipName } ' not found.") ;
132
127
}
133
128
134
129
var resource = MapOut ( entity ) ;
135
130
136
- var relationship = _jsonApiContext . ContextGraph . GetRelationship ( resource , navigationPropertyName ) ;
131
+ // compound-property -> CompoundProperty
132
+ var navigationPropertyName = _jsonApiContext . ContextGraph . GetRelationshipName < TResource > ( relationshipName ) ;
133
+ if ( navigationPropertyName == null )
134
+ throw new JsonApiException ( 422 , $ "Relationship '{ relationshipName } ' does not exist on resource '{ typeof ( TResource ) } '.") ;
137
135
138
- return relationship ;
136
+ var relationshipValue = _jsonApiContext . ContextGraph . GetRelationship ( resource , navigationPropertyName ) ;
137
+ return relationshipValue ;
139
138
}
140
139
141
140
public virtual async Task < TResource > UpdateAsync ( TId id , TResource resource )
0 commit comments