Saving Multiple Children Transaction / IsDirty Problem

Saving Multiple Children Transaction / IsDirty Problem

Old forum URL: forums.lhotka.net/forums/t/3617.aspx


rahulbpatel posted on Friday, September 28, 2007

I have an Order root object that has three child objects:

    Order Root BO

       Items Child 1 BO (collection)

       Shipping Info Child 2 BO

       Payment Info Child 3 BO

I am having a problem where in the Order DataPortal_Insert the insert calls to children 1 and 2 are successful, but child 3 fails with an exception because it also calls an external payment processor to authorize payment on an insert.  The exception is caught by the ASP.NET UI code and presented to the user and the Data_PortalInsert is marked with [Transactional(TransactionalTypes.TransactionScope)] so nothing is committed in the database.  The problem is that if the user corrects the payment information and then re-saves, children 1 and 2 updates are not called because they were marked as old in the first save. 

Is there a way to handle this situation?

JoeFallon1 replied on Friday, September 28, 2007

I think you are supposed to Clone the Root BO as part of the Save. And if there is an Exception you re-set your local variable to the Cloned copy so that your object state is back to what it was prior to calling Save the first time. Rocky has discussed this many times. Check the books and his blog and other threads here for a sample.

Joe

 

Copyright (c) Marimer LLC