mihies wrote:
Imagine you have a parent and child entity. Load a parent instance. Create new child instance and link it to parent instance through child's property. Create another child instance and link it to parent.
Add first child instance to UnitOfWork2 and serialize UoW.
The question: What will contain (and try to save when Commit) UoW?
Depends if you've specified to recursively save the entity you added. You can specify not to recursively save the graph.
When you set OptimizedSerialization to true, the UoW will first calculate the save queues and then serialize the entities in the save queue. A known issue currently is that in your situation parent and the other child will still be serialized as they're in the graph reachable from the child to save.
When saving, the entity which is added for save (but not recurse) is then saved. When you used the overloads to add an entity without specifying the recurse flag, the save is recursive, and parent and the other child will be saved as well.