/// <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); }
/// <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); }
/// <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); }
public UnitOfWork(IDbConnection connection) { if (connection == null) { throw new ArgumentNullException("connection"); } _connection = connection; _transaction = SqlTransactions.BeginTransaction(connection); }
/// <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); }