UnitOfWork Failling Action

Posts   
 
    
mohamed avatar
mohamed
User
Posts: 136
Joined: 10-Mar-2008
# Posted on: 25-Jan-2009 11:25:11   

Greeting,

What about UnitOfWork !!!

let's put this example collections of entities (300 entities or more) will be save and delete from database, This is piece of cake (by AddForSave and AddForDelete to UOW), But when one of these entities failed (like Entity No 200), I want to commit all previous entities (i.e All 199 entities) and return from failed.

I should do all with one trip to database ??

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 25-Jan-2009 20:17:47   

Hi mohamed,

That is one of the purposes of the Unit of Work: perform these actions in one go. So inside the UOW's commit exists a transaction, so if one action (insert, update, delete, etc) fails, then all actions will be rollback.

The thing is: if an entity fails, it fails for a reason, and that reason is likely causing problems no matter what so the user (if the user can help it) should fix it (new data) or the software should fix it.

If the work is really a set of saves which don't really belong to 1 transaction, you should do separate saves.

David Elizondo | LLBLGen Support Team