Apparently (because the documentation doesn’t say any word of this), in a .NET Transaction (using TransactionScope), the rollbacks are done in the same order as the commits would be, and in the same order as the registrations were done.
Logically, rollback should be in reverse order:
If an action sequence is “do A” then “do B”, my rollback sequence should be “undo B”, then “undo A”. But thanks to TransactionScope it’s not, it’s always “undo A”, then “undo B”.
Did I miss an option, or shall I die with this strange ordering ? 🙂
According to Microsoft, if your transaction scope goes “out of scope” (i.e. if you throw an exception from within the transaction scope) before the Complete() method is executed, the transaction within that scope should get rolled back immediately.
It follows that, if you want your transactions to roll back in reverse order, you should nest them. See the following article for more information:
Implementing an Implicit Transaction using Transaction Scope
http://msdn.microsoft.com/en-us/library/ms172152.aspx