TransactionScope Hierarchy

Is it possible to have a hierarchy of transaction areas?

If the outer transaction scope deletes, what will happen to the changes made to the inner transaction scope?

My particular problem is that I have test code that runs code with transaction scope. When I call the second set of code with a transaction scope, I get "Unable to access the remote object. Transaction." It may be that deleting the internal transaction area also deletes the external transaction area.

+3
source share
3 answers

I doubt that this is what happens. TransactionScopes can be nested if the underlying technology supports distributed transactions, if necessary. For example, if you start a transaction and update some data in database A, and then call a function inside this function, you create a new TransactionScope and insert some data into database B, then the internal transaction uses "ambient", a transaction that was already is open. However, for this you need a distributed transaction coordinator (for SQL servers). In addition, SQL Server 2005 and later can start a transaction as a regular transaction and distribute it to a distributed transaction, if necessary, while SQL 2000 will start all of them as distributed transactions, because it does not have the ability to promote them.

, , .

.

TransactionScopeOption; , .

+3

, . , , . , .

, ? . .

+2

, . , , , .

- (.. TransactionScopeOption) , .

"disposed" . .

+1

Source: https://habr.com/ru/post/1716101/


All Articles