I have a need to update (Save/Add/Delete) multiple business objects for a particular process. I would like all the database access to occur under a single transaction so that the if any part of it blows up the transaction will not be committed. I am using the ConnectionManager for my DB access.
My first thought was to do a DataPortal_Execute with a TransactionScope attribute and then do all the BusinessObject activity in that Execute procedure. That way whether it runs locally or on the server the Execute would wrap everything else. I'm worried that it requires a lot of parameters and business objects to be passed into and out of the Execute and will have to pass the saved objects back to the client via the Criteria.
Is there a preferred way to do this?
For example, I am writing an AR application that has an CustomerAccount BusinessBase object. If data is changed in that object (sometimes) it needs to update the ledger which requires the creation of a batch (a BusinessBase object), addition of batch transactions (Child BusinessBase objects) and posting the batch (a CommandObject execute). If any part of this sequence fails, then whole sequence should be rolled back. I need the saves CustomerAccount object and the posted/saved batch back
Thoughts are greatly appreciated.
PS I am using CLSA 3.8 in a Windows Forms application, no LINQ. DB is SQL Server
Use a unit of work object as discussed in the FAQ (http://www.lhotka.net/cslanet/faq/CslaObjectFaq.ashx) and in the Using CSLA 4 ebook series.
Copyright (c) Marimer LLC