Ejemplo n.º 1
0
        private void Insert_TransactionRollbackButton_Click(object sender, EventArgs e)
        {
            // Transaction
            using (var transaction = new SqlTransactionScope())
            {
                try
                {
                    // Insert
                    this.InsertData();

                    // Throw
                    throw new Exception();

                    // Complete
                    transaction.Complete();
                }
                catch
                {
                    // ......
                }
            }

            // Refresh
            this.RefreshData();
        }
Ejemplo n.º 2
0
        // Methods
        public TransactionScopeProvider Create()
        {
            // TransactionScope
            var transactionScope = new SqlTransactionScope();

            // TransactionScopeProvider
            var transactionScopeProvider = new SqlTransactionScopeProvider(transactionScope);

            // Return
            return(transactionScopeProvider);
        }
Ejemplo n.º 3
0
        // Methods
        public IUnitOfWorkScope Create()
        {
            // TransactionScope
            SqlTransactionScope transactionScope = new SqlTransactionScope();

            // UnitOfWorkScope
            IUnitOfWorkScope unitOfWorkScope = new SqlUnitOfWorkScope(transactionScope);

            // Return
            return(unitOfWorkScope);
        }
Ejemplo n.º 4
0
        // Constructors
        public SqlUnitOfWorkScope(SqlTransactionScope transactionScope)
        {
            #region Contracts

            if (transactionScope == null)
            {
                throw new ArgumentNullException();
            }

            #endregion

            // Arguments
            _transactionScope = transactionScope;
        }
Ejemplo n.º 5
0
        // Constructors
        public SqlTransactionScopeProvider(SqlTransactionScope transactionScope)
        {
            #region Contracts

            if (transactionScope == null)
            {
                throw new ArgumentNullException();
            }

            #endregion

            // Default
            _transactionScope = transactionScope;
        }