Will the nested transactions be rolled back when the root one rolls back?
c#, rollback, sql-server, transactions, transactionscope
Solution
nestedOne will join the root scope, so if the root scope will rollback, nestedOne will be roll back as well, but not nestedTwo which is a seperate transaction.
like you have the "RequireNew" option that seperate the transaction from the enclosing transaction you can have the "Suppress" option that stops the transaction for that scope.
Take a look at the following list from MSDN that gives a great lesson about transactions behaviour. http://msdn.microsoft.com/en-us/library/ms172152(v=vs.90).aspx
Problem
In this code.. ``` public static TransactionScope CreateTransactionScope(bool createNew = false) { return new TransactionScope( createNew ? TransactionScopeOption.RequiresNew : TransactionScopeOption.Required, new TransactionOptions() { IsolationLevel = IsolationLevel.ReadCommitted }); } ``` Actually, in this one... ``` using (TransactionScope rootScope = CreateTransactionScope()) { using (TransactionScope nestedOne = CreateTransactionScope()) { nestedOne.Complete(); } using (TransactionScope nestedTwo = CreateTransactionScope(true)) { nestedTwo.Complete(); } // No committing, rollback 'rootScope'. } ``` What transactions will be rolled back along with the root one - will it be only `nestedOne` or both `nestedOne` and `nestedTwo`?