user355562
user355562

Reputation: 3373

How can asp.net TransactionScope rollback a transaction after the connection is closed?

Suppose say I am doing a couple of operations.

First a delete and then an insert.

Now, these two operations are done with two different connections (say con1 and con2). Both these connections are enlisted in the same TransactionScope.

Before the delete/insert operations the connections are opened and immediately closed.

So, now if the insert fails, then how is the delete rollbacked since con1 has been closed?

Thanks!

Upvotes: 0

Views: 899

Answers (1)

Franci Penov
Franci Penov

Reputation: 76001

The underlying database has a transaction log, where all actions associated with particular transaction context are stored. This log is independent of the actual connection to the DB to perform particular action. The rollback is atomic and covers all the actions in the transaction log for this particular transaction.

Upvotes: 1

Related Questions