unit of work sequencing

Posts   
 
    
Jamanga
User
Posts: 93
Joined: 21-Jul-2006
# Posted on: 02-Oct-2009 03:29:16   

Hi

I was using the unitofwork collection when saving some parent/child entities and it works really, really well.

I did have to change the sequence of processing due to uniqueness constraints, which would cause the commit to fail if they weren't removed first i.e. via:

List<UnitOfWorkBlockType> newCommitOrder = new List<UnitOfWorkBlockType>();
newCommitOrder.Add(UnitOfWorkBlockType.Deletes);
newCommitOrder.Add(UnitOfWorkBlockType.Inserts);
newCommitOrder.Add(UnitOfWorkBlockType.Updates);

I was wondering why this sequence isn't the "default" behaviour, as it seems to make more sense, to me anyway i.e. delete first, then insert or update as appropriate?

As always, thanks for this great product! James

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 02-Oct-2009 09:21:54   

Why not Inserts/Updates/Deletes... or Updates/Inserts/Deletes?

I think the Deletes were left to the end to avoid any refrential violations as the UOW normally spans multiple tables/entities.

Anyway it's not a big deal as it differs from a scenario to the other, and it is left to the developer to modify the default behaviour.