c# - Linq to SQL: Updating an aggregate root -
I have an object in which nested parts are maintained on three tables. These classes are for ILIT and lieutenant;> relations with POCO, no relation on any framework.
A_object-> B_object [N] - & gt; C_object [N]
I send this item to a repository to update. The content is retained using the SQL from the repository Linq.
myRepo.Update (A_object);
The first loop that handles updates and deletes:
foreach (AB_records in var b) {foreach (var cc records) {if (C is in our parameter object) // database object object update / not found, delete database object} If (b is in our parameter object) // database object object update / not updated, delete database object}
found in our parameter object Or if our parameter is not found in the object, then the database records the loop database records when the recorder is removed. Thus updating and deleting are OK.
Given that I can not modify the square of the parameter object, there are some patterns or mechanics, I apply the database to include the remaining B and C objects without any need. Can i
Obviously I can make an array for the primary key of B and C, then leave them on the insert loop, but do not I have any better way?
We have a pattern where I am working. Generally we do one of the two things:
- Set the field "ISNew" for "true" on objects that were not previously in the database, or
Comments
Post a Comment