Skip to content

Commit 7f49ef9

Browse files
committed
feat(de-serializer): store which relationships should be updated
1 parent 0f2ba28 commit 7f49ef9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/JsonApiDotNetCore/Serialization/JsonApiDeSerializer.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,18 @@ private object _setHasOneRelationship(object entity,
141141

142142
if (relationships.TryGetValue(relationshipName, out RelationshipData relationshipData))
143143
{
144+
var relationshipAttr = _jsonApiContext.RequestEntity.Relationships
145+
.SingleOrDefault(r => r.PublicRelationshipName == relationshipName);
146+
144147
var data = (Dictionary<string, string>)relationshipData.ExposedData;
145148

146149
if (data == null) return entity;
147150

148151
var newValue = data["id"];
149152
var convertedValue = TypeHelper.ConvertType(newValue, entityProperty.PropertyType);
153+
154+
_jsonApiContext.RelationshipsToUpdate[relationshipAttr] = convertedValue;
155+
150156
entityProperty.SetValue(entity, convertedValue);
151157
}
152158

0 commit comments

Comments
 (0)