This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

UnitOfWork clarification

Hi,

The UnitOfWOrk object seems to be useful when you have a lot of objects to update...you Put them in the UnitOfWork and them commit the whole thing.  As the script sample in the SDK says:

'* IUnitOfWork contains a caching mechanism for IEntity instances
'* It caches registered objects and delivers them
'* from the cache instead of realoading them.

Just to clarify: does this mean that all those changes that are Put in the UnitOfWork are treated as a transaction (as in all or nothing) or would one have to explicitly set up transactions for that?

What would be the difference with opening a Transaction on the Connection object and then running thru the Objects Saving them and then committing the Transaction at the end?

thanks,

Rob.

  • Hi Rob,

    the UnitOfWork is treated as a transaction as in all or nothing. The additional advantage of using a UnitOfWork is, that the object layer is able to group the operations and can use bulk mode to write the data into the database.

    If you open a database on your own you are loosing the bulk optimization.

    The UnitOfWork implicitly opens a database transaction during the first put operation.

    HtH