Nested TransactionScopes with LINQ and datacontext transactionscopeabortedexception transaction has aborted
I am getting a TransactionAbortedException "Transaction has aborted" when I try to instantiate the second of many nested TransactionScopes. 

I have some functions that perform database procedures using linq, some of which use a TransactionScope object.

Now I have a new function that needs to call more than one of these other functions, and if any of them fails it needs to roll everything back - so I also use a transactionscope here.

The problem is once the first sub-function completes its own transactionscope, the next sub-function fails when I try to instantiate a new transactionscope object:

        private void RegisterBusiness()
        {            
            using (var trans1 = new TransactionScope())
            {
                addNewBusiness();
                addDocuments();

                trans1.Complete();
            }
        }

        public void addNewBusiness()
        {
            using (var trans2 = new TransactionScope())
            {
                using (var db = new ExampleDataContext())
                {
                    var newAuthor = new Business();
                    //...
                    db.Businesses.InsertOnSubmit(newAuthor);
                    db.SubmitChanges();

                    var newUser = newUser();
                    //...
                    db.Users.InsertOnSubmit();
                    db.SubmitChanges();

                    trans2.Complete();
                }
            }
        }

        public void addDocuments()
        {
            using (var trans3 = new TransactionScope()) //TransactionAbortedException here : The Transaction has aborted.
            {
                // never gets here...
                trans3.Complete();
                
            }          
        }

The transactions all behave fine until I insert the records and submit the changes to the data context (e.g. if I comment out the insert/submitchanges, the transactions behave properly). I initially thought it could be something with the implicit datacontext, so I rearranged the code to pass around one single instance of the datacontext, but that still gave the same error.

Does anyone know of any issues with using linq datacontexts and nested TransactionScopes?

Thanks

Rusty
Nested TransactionScopes with LINQ and datacontext transactionscopeabortedexception transaction has aborted
===

I am getting a TransactionAbortedException "Transaction has aborted" when I try to instantiate the second of many nested TransactionScopes. 

I have some functions that perform database procedures using linq, some of which use a TransactionScope object.

Now I have a new function that needs to call more than one of these other functions, and if any of them fails it needs to roll everything back - so I also use a transactionscope here.

The problem is once the first sub-function completes its own transactionscope, the next sub-function fails when I try to instantiate a new transactionscope object:

        private void RegisterBusiness()
        {            
            using (var trans1 = new TransactionScope())
            {
                addNewBusiness();
                addDocuments();

                trans1.Complete();
            }
        }

        public void addNewBusiness()
        {
            using (var trans2 = new TransactionScope())
            {
                using (var db = new ExampleDataContext())
                {
                    var newAuthor = new Business();
                    //...
                    db.Businesses.InsertOnSubmit(newAuthor);
                    db.SubmitChanges();

                    var newUser = newUser();
                    //...
                    db.Users.InsertOnSubmit();
                    db.SubmitChanges();

                    trans2.Complete();
                }
            }
        }

        public void addDocuments()
        {
            using (var trans3 = new TransactionScope()) //TransactionAbortedException here : The Transaction has aborted.
            {
                // never gets here...
                trans3.Complete();
                
            }          
        }

The transactions all behave fine until I insert the records and submit the changes to the data context (e.g. if I comment out the insert/submitchanges, the transactions behave properly). I initially thought it could be something with the implicit datacontext, so I rearranged the code to pass around one single instance of the datacontext, but that still gave the same error.

Does anyone know of any issues with using linq datacontexts and nested TransactionScopes?

Thanks

Rusty