Skip to content

Commit c5bcaad

Browse files
authored
Merge pull request #106 from Research-Institute/hotfix/null-ref-include
fix null ref on GetRelationshipsAsync
2 parents 9daab2e + 5ef646b commit c5bcaad

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/JsonApiDotNetCore/Internal/ContextGraph.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public string GetRelationshipName<TParent>(string relationshipName)
4646
e.EntityType == entityType)
4747
.Relationships
4848
.FirstOrDefault(r =>
49-
r.InternalRelationshipName.ToLower() == relationshipName.ToLower())
49+
r.PublicRelationshipName.ToLower() == relationshipName.ToLower())
5050
?.InternalRelationshipName;
5151
}
5252
}

src/JsonApiDotNetCore/JsonApiDotNetCore.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<VersionPrefix>2.0.2</VersionPrefix>
3+
<VersionPrefix>2.0.3</VersionPrefix>
44
<TargetFrameworks>netstandard1.6</TargetFrameworks>
55
<AssemblyName>JsonApiDotNetCore</AssemblyName>
66
<PackageId>JsonApiDotNetCore</PackageId>

src/JsonApiDotNetCore/Services/EntityResourceService.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ public async Task<object> GetRelationshipAsync(TId id, string relationshipName)
9292
if (relationshipName == null)
9393
throw new JsonApiException("422", "Relationship name not specified.");
9494

95+
_logger.LogTrace($"Looking up '{relationshipName}'...");
96+
9597
var entity = await _entities.GetAndIncludeAsync(id, relationshipName);
9698
if (entity == null)
9799
throw new JsonApiException("404", $"Relationship {relationshipName} not found.");
@@ -116,7 +118,7 @@ public async Task<T> UpdateAsync(TId id, T entity)
116118
public async Task UpdateRelationshipsAsync(TId id, string relationshipName, List<DocumentData> relationships)
117119
{
118120
relationshipName = _jsonApiContext.ContextGraph
119-
.GetRelationshipName<T>(relationshipName.ToProperCase());
121+
.GetRelationshipName<T>(relationshipName);
120122

121123
if (relationshipName == null)
122124
throw new JsonApiException("422", "Relationship name not specified.");

0 commit comments

Comments
 (0)