Exemple #1
0
        /// <summary>
        ///   Rolbacks actual transaction and sets auto transaction for related connection to null.</summary>
        public void Dispose()
        {
            var connection = _transaction.Connection;

            _transaction.Dispose();
            SqlTransactions.SetDefaultTransaction(connection, null);
        }
Exemple #2
0
        /// <summary>
        ///   Rollbacks actual transaction and sets auto transaction for related connection to null.</summary>
        public void Rollback()
        {
            var connection = _transaction.Connection;

            _transaction.Rollback();
            SqlTransactions.SetDefaultTransaction(connection, null);
        }
Exemple #3
0
        /// <summary>
        ///   Commits actual transaction and sets auto transaction for related connection to null.</summary>
        public void Commit()
        {
            var connection = _transaction.Connection;

            _transaction.Commit();
            SqlTransactions.SetDefaultTransaction(connection, null);
        }
Exemple #4
0
        public UnitOfWork(IDbConnection connection)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }

            _connection  = connection;
            _transaction = SqlTransactions.BeginTransaction(connection);
        }
Exemple #5
0
        /// <summary>
        ///   İstenen bağlantıya bağlı ve verilen komutu içeren yeni bir IDbCommand nesnesi oluşturur.</summary>
        /// <param name="connection">
        ///   IDbCommand nesnesinin oluşturulacağı bağlantı.</param>
        /// <param name="commandText">
        ///   IDbCommand nesnesinin içereceği komut metni. <c>null</c> olabilir.</param>
        /// <returns>
        ///   Yeni IDbCommand nesnesi.</returns>
        public static IDbCommand NewCommand(IDbConnection connection, string commandText)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }

            IDbCommand command = connection.CreateCommand();

            command.Connection  = connection;
            command.CommandText = commandText;
            command.Transaction = SqlTransactions.GetCurrentTransaction(connection);
            return(command);
        }