Is UnitOfWork all or nothing - v8.0.1?

Hello Experts,

I have a large number of objects in my UnitOfWork, and it is possible that a few might cause an error when saved. In this scenario, will the uow not save (i.e. commit to database) any object at all, or will it save all objects which didnt generated any errors? I'm looking for enabling the latter behaviour in case it is not the default, any way to do that?

Thanks

Kin

Parents Reply Children
  • No, it will not. If you choose to set ContinueOnError = True, the UnitOfWork is not throwing an exception when an error occurs. Instead, you need to check the Invalid property. If the property is true, then an error had occurred and the UoW had already written out some DML (Data Manipulation Language) aka SQL code. You would need to throw an exception in that case to initiate the rollback of the underlying transaction of the UoW.