Class NpgsqlTransaction
- Namespace
- Npgsql
- Assembly
- Npgsql.dll
Represents a transaction to be made in a PostgreSQL database. This class cannot be inherited.
public sealed class NpgsqlTransaction : DbTransaction, IDbTransaction, IDisposable, IAsyncDisposable
- Inheritance
-
NpgsqlTransaction
- Implements
- Inherited Members
Properties
Connection
Specifies the NpgsqlConnection object associated with the transaction.
public NpgsqlConnection? Connection { get; }
Property Value
- NpgsqlConnection
The NpgsqlConnection object associated with the transaction.
DbConnection
Specifies the NpgsqlConnection object associated with the transaction.
protected override DbConnection? DbConnection { get; }
Property Value
- DbConnection
The NpgsqlConnection object associated with the transaction.
IsolationLevel
Specifies the isolation level for this transaction.
public override IsolationLevel IsolationLevel { get; }
Property Value
- IsolationLevel
The isolation level for this transaction. The default is ReadCommitted.
SupportsSavepoints
Indicates whether this transaction supports database savepoints.
public override bool SupportsSavepoints { get; }
Property Value
Methods
Commit()
Commits the database transaction.
public override void Commit()
CommitAsync(CancellationToken)
Commits the database transaction.
public override Task CommitAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenAn optional token to cancel the asynchronous operation. The default value is None.
Returns
Dispose(bool)
Disposes the transaction, rolling it back if it is still pending.
protected override void Dispose(bool disposing)
Parameters
disposing
bool
DisposeAsync()
Disposes the transaction, rolling it back if it is still pending.
public override ValueTask DisposeAsync()
Returns
Release(string)
Releases a transaction from a pending savepoint state.
public override void Release(string name)
Parameters
name
stringThe name of the savepoint.
ReleaseAsync(string, CancellationToken)
Releases a transaction from a pending savepoint state.
public override Task ReleaseAsync(string name, CancellationToken cancellationToken = default)
Parameters
name
stringThe name of the savepoint.
cancellationToken
CancellationTokenAn optional token to cancel the asynchronous operation. The default value is None.
Returns
Rollback()
Rolls back a transaction from a pending state.
public override void Rollback()
Rollback(string)
Rolls back a transaction from a pending savepoint state.
public override void Rollback(string name)
Parameters
name
stringThe name of the savepoint.
RollbackAsync(string, CancellationToken)
Rolls back a transaction from a pending savepoint state.
public override Task RollbackAsync(string name, CancellationToken cancellationToken = default)
Parameters
name
stringThe name of the savepoint.
cancellationToken
CancellationTokenAn optional token to cancel the asynchronous operation. The default value is None.
Returns
RollbackAsync(CancellationToken)
Rolls back a transaction from a pending state.
public override Task RollbackAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenAn optional token to cancel the asynchronous operation. The default value is None.
Returns
Save(string)
Creates a transaction save point.
public override void Save(string name)
Parameters
name
stringThe name of the savepoint.
Remarks
This method does not cause a database roundtrip to be made. The savepoint creation statement will instead be sent along with the next command.
SaveAsync(string, CancellationToken)
Creates a transaction save point.
public override Task SaveAsync(string name, CancellationToken cancellationToken = default)
Parameters
name
stringThe name of the savepoint.
cancellationToken
CancellationTokenAn optional token to cancel the asynchronous operation. The default value is None.
Returns
Remarks
This method does not cause a database roundtrip to be made, and will therefore always complete synchronously. The savepoint creation statement will instead be sent along with the next command.