UnitOfWork2.Commit Exceptions?

Posts   
 
    
Emmanuel
User
Posts: 167
Joined: 13-Jan-2006
# Posted on: 28-Mar-2009 11:46:30   

I am looking into using UnitOfWork2 objects for the first time. I couldn't figure out how to determine what DB errors occur during a failed commit.

The reference documentation says that UnitOfWork2.Commit can throw only one type of exception: ArgumentNullException.

After reading a whole bunch of posts on this forum I've got a tentative conclusion that UnitOfWork2.Commit will, in fact, throw some ORM exceptions.

Is this a documentation bug? If so, what is the list of exceptions that I can expect UnitOfWork2.Commit() to throw?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 28-Mar-2009 14:28:23   

The documentation might be less optimal in this case, as is with most MSDN docs from ms: it doesnt always document all exceptions which could be thrown by code called by the class at hand, in this case unitofwork(2).

The unitofwork uses the same code for saving and deleting entities as the dataaccessadapter, so you can expect the same exceptions as from these methods, e.g. validation exceptions if validation fails, concurrency exceptions if updates didn't update a row, query construction exceptions if the entities to update /delete didn't have a pk defined, plus the queryexecution exception when the query in general fails (inside the db)

Frans Bouma | Lead developer LLBLGen Pro