Closed
Description
PATCH request for entities having relationships doesn't save them.
For HasOne
relationships possible solution is to have code like this in DefaultRepository.UpdateAsync
:
_jsonApiContext.RequestEntity.Relationships.ForEach(rel =>
{
if (rel.IsHasOne)
{
var propertyInfo = entity.GetType().GetProperty($"{rel.InternalRelationshipName}Id");
propertyInfo.SetValue(oldEntity, propertyInfo.GetValue(entity));
}
});
However with HasMany
I am not sure what is the right way. Looking to what ember-data sends, it seems that "direct" (meaning that it's not many-to-many relationship) has-many relationships are not sent with entity. Instead you should save them separately.