У меня есть эта сущность, у которой много связанных записей.Когда веб-клиент сохраняет данные, он отправляет иерархическую модель JSON.Модели выглядят так:
Product[].properties
.SET1[].properties
.SET2[].properties
.SETA[].properties
.SETA[].SETb[].properties
Когда я сохраняю это, у меня следующий поток:
Grab DB Product that matches current
Update Properties
Grab and loop through set 1 from DB
If not found in "to save" set, delete item from set 1
If found, update it
Grab and loop through set 2 from DB
If not found in "to save" set, delete item from set 2
If found, update it
While we are in Set 2, grab all Set A from DB
If not found in "to save" set, delete it from set A
If found, update it
While we are in Set A, grab all Set b in DB
If not found in "to save" set, delete it from set b
If found, update it
Now go back through and insert any in local set not in DB
Это должен быть худший алгоритм обновления, который я когда-либо видел.У кого-нибудь есть лучший код или ссылки, которые могут быть немного проще?В настоящее время используется C #