コード例 #1
0
ファイル: SqlUnitOfWorkScope.cs プロジェクト: Clark159/CLK
        // Constructors
        public SqlUnitOfWorkScope(SqlTransactionScope transactionScope)
        {
            #region Contracts

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

            #endregion

            // Arguments
            _transactionScope = transactionScope;
        }
コード例 #2
0
        // Methods
        public IUnitOfWorkScope Create()
        {
            // TransactionScope
            SqlTransactionScope transactionScope = new SqlTransactionScope();

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

            // Return
            return unitOfWorkScope;
        }
コード例 #3
0
ファイル: SqlCommandScope.cs プロジェクト: wushian/CLK
        // Constructors
        public SqlCommandScope(string connectionString)
        {
            #region Contracts

            if (string.IsNullOrEmpty(connectionString) == true)
            {
                throw new ArgumentNullException();
            }

            #endregion

            // Transaction Command
            SqlCommand command = SqlTransactionScope.Create(connectionString);
            if (command != null)
            {
                // Connection
                _connection = null;

                // Command
                _command = command;

                // Return
                return;
            }

            // Normal Command
            if (command == null)
            {
                // Connection
                _connection = new SqlConnection(connectionString);
                _connection.Open();

                // Command
                _command            = new SqlCommand();
                _command.Connection = _connection;

                // Return
                return;
            }
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: Clark159/CLK
        private void Insert_TransactionCommitButton_Click(object sender, EventArgs e)
        {
            // Transaction
            using (var transaction = new SqlTransactionScope())
            {
                try
                {
                    // Insert
                    this.InsertData();

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

            // Refresh
            this.RefreshData();
        }