.NET TransactionScope rollback order

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 ? :)

13.10.2009 17:26:15
1 ОТВЕТ
РЕШЕНИЕ

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

0
13.10.2009 17:35:12
I'm using transactions to implement a transactional filesystem (sort of). File operations can be done in a random order, and MUST be undone in reverse order. So I can not nest transactions. I guess I'm screwed and need to write my own list of file operations to reverse them in right order.
picrap 13.10.2009 17:40:51
Mr. Picrap, any solution about your needs ??
Kiquenet 21.07.2010 16:09:33