Class SqlTransactionContext
Owns a database connection and a single transaction for the lifetime of an operation.
public class SqlTransactionContext : IDisposable
- Inheritance
-
SqlTransactionContext
- Implements
- Inherited Members
- Extension Methods
Constructors
SqlTransactionContext(DbConnection)
Constructor.
public SqlTransactionContext(DbConnection Connection)
Parameters
ConnectionDbConnection
Properties
Connection
Returns the owned connection.
public DbConnection Connection { get; }
Property Value
IsActive
Returns true when the transaction is active.
public bool IsActive { get; }
Property Value
IsCompleted
Returns true when the transaction has been committed or rolled back.
public bool IsCompleted { get; }
Property Value
Transaction
Returns the owned transaction.
public DbTransaction Transaction { get; }
Property Value
Methods
BeginTransaction()
Opens the connection, if needed, and begins the transaction.
public void BeginTransaction()
Commit()
Commits the transaction.
public void Commit()
Dispose()
Disposes the transaction and the connection.
public void Dispose()
Rollback()
Rolls back the transaction.
public void Rollback()