Note that there are some explanatory texts on larger screens.

plurals
  1. POTransactionScope and rolling back object state
    primarykey
    data
    text
    <p>I'm looking for a solution to a design problem. This will take a bit of explaining. I would post code, but that woul make this even longer. </p> <p>I have a custom generic collection I use to hold Business Objects as needed. For easy of reference, call the business objects <strong>BO</strong> and the generic collection <strong>GC</strong>. Inside GC I have a private collection of those business objects that have been flagged for deletion. Call this private collection <strong>PDC</strong>. </p> <p>I can have an arbitrary number of GC's, each with their own PDC, at any one time, plus other BOs that aren't in any collection.</p> <p>When I save changes I loop over all BO and GC and have each one save their changes. This happens wrapped in a TransactionScope so I rollback database changes if anything fails to save properly. </p> <p>When a GC saves I have a problem with the state of its PDC. The GC first saves all BOs with updates, then deletes records associated with the BOs in the PDC, then <strong>clears the PDC of all BOs</strong>. I do this so the state of the GC correctly reflects the new state of the database. </p> <p>Now suppose a BO or GC fails to save after one or more of the GC has successsfully saved . The TransactionScope performs a rollback. The records deleted from the database are restored, <strong>but the some/all of the PDC's have been cleared and that state information lost</strong>.</p> <p>So here is my quandry: How do I keep the PDC information around until after the commit has occured, then guarantee the appriopriate collections are cleared? </p> <p>TransactionScope has no event I can catch to let me know when it the changes have been committed. There are potentially MANY BOs and GC affected by any given transaction, so I can't restrict the transaction to handle one GC at a time. </p> <p>Any suggestions?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload