-
-
Notifications
You must be signed in to change notification settings - Fork 160
Closed
Labels
Description
Discovered in v2.4.0-beta3
JsonApiException: N2JsonApi.Models.Item does not contain a relationship named ...
JsonApiDotNetCore.Internal.ContextGraph in GetRelationship
JsonApiDotNetCore/src/JsonApiDotNetCore/Internal/ContextGraph.cs
Lines 51 to 63 in 271693a
| public object GetRelationship<TParent>(TParent entity, string relationshipName) | |
| { | |
| var parentEntityType = entity.GetType(); | |
| var navigationProperty = parentEntityType | |
| .GetProperties() | |
| .SingleOrDefault(p => string.Equals(p.Name, relationshipName, StringComparison.OrdinalIgnoreCase)); | |
| if (navigationProperty == null) | |
| throw new JsonApiException(400, $"{parentEntityType} does not contain a relationship named {relationshipName}"); | |
| return navigationProperty.GetValue(entity); | |
| } |
Update
Need to improve API documentation so it is more clear what these methods do.
Also, need to add tests with compound (or just different) attribute names.