Код: Выделить всё
{
"id": null,
"child": [
{
"id": null,
"parentId": null
"quantity": 1,
"rate": 5.5
},
{
"id": null,
"parentId": null,
"quantity": 15,
"rate": 75.5
}
]
}
Теперь, если я отправлю это полезная нагрузка для обновления дочерних объектов, это тоже работает.
Код: Выделить всё
{
"id": "365A71AD-8625-4701-904B-E21DCF62E343",
"child": [
{
"id": "BC889B2F-1BFD-4E3E-9C23-078948A16ED5",
"parentId": "365A71AD-8625-4701-904B-E21DCF62E343"
"quantity": 999,
"rate": 150
},
{
"id": "F56C9F80-0238-4F03-9CA0-D591FCFE3537",
"parentId": "365A71AD-8625-4701-904B-E21DCF62E343",
"quantity": 115,
"rate": 5
}
]
}
Код: Выделить всё
var incomingNavigationProperties = databaseContext.Entry(incomingDtoCastedToDatabaseType).Navigations;
var existingNavigationProperties = databaseContext.Entry(existingEntityFetchedFromDatabase).Navigations;
foreach(var navObj in incomingNavigationProperties)
{
foreach(var navExist in existingNavigationProperties)
{
if(navObj.Metadata.Name == navExist.Metadata.Name)
{
navExist.CurrentValue = navObj.CurrentValue;
}
}
}
Спасибо.
Подробнее здесь: https://stackoverflow.com/questions/792 ... ent-entity