Exemplo n.º 1
0
        //public void Create_ThrowExceptionAfterSecondSaveChangesWithScope(Guid key)
        //{
        //    using (TransactionScope scope = new TransactionScope())
        //    {
        //        try
        //        {
        //            _repo1.CreateWithNoTransaction(key);
        //            _repo2.Create_ThrowExceptionAfterSaveChangesWithNoTransaction(key);

        //            scope.Complete();
        //        }
        //        catch (Exception)
        //        {
        //            throw;
        //        }
        //    }
        //}

        public void Create_ThrowExceptionAfterSecondSaveChangesWithScope(Guid key)
        {
            _transactionProvider.BeginTransaction();

            try
            {
                _repo1.CreateWithNoTransaction(key);
                _repo2.Create_ThrowExceptionAfterSaveChangesWithNoTransaction(key);

                _transactionProvider.CommitTransaction();
            }
            catch (Exception)
            {
                _transactionProvider.RollbackTransaction();
                throw;
            }
            finally
            {
                _transactionProvider.DisposeTransaction();
            }
        }