Class NpgsqlTransaction
Represents a transaction to be made in a PostgreSQL database. This class cannot be inherited.
Inheritance
Implements
Inherited Members
Namespace: Npgsql
Assembly: Npgsql.dll
Syntax
public sealed class NpgsqlTransaction : DbTransaction, IDbTransaction, IDisposable
Properties
Connection
Specifies the NpgsqlConnection object associated with the transaction.
Declaration
public NpgsqlConnection Connection { get; }
Property Value
Type | Description |
---|---|
NpgsqlConnection | The NpgsqlConnection object associated with the transaction. |
DbConnection
Specifies the NpgsqlConnection object associated with the transaction.
Declaration
protected override DbConnection DbConnection { get; }
Property Value
Type | Description |
---|---|
System.Data.Common.DbConnection | The NpgsqlConnection object associated with the transaction. |
Overrides
IsCompleted
Specifies the completion state of the transaction.
Declaration
public bool IsCompleted { get; }
Property Value
Type | Description |
---|---|
System.Boolean | The completion state of the transaction. |
IsolationLevel
Specifies the System.Data.IsolationLevel for this transaction.
Declaration
public override IsolationLevel IsolationLevel { get; }
Property Value
Type | Description |
---|---|
System.Data.IsolationLevel | The System.Data.IsolationLevel for this transaction. The default is ReadCommitted. |
Overrides
Methods
Commit()
Commits the database transaction.
Declaration
public override void Commit()
Overrides
CommitAsync()
Commits the database transaction.
Declaration
public Task CommitAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
CommitAsync(CancellationToken)
Commits the database transaction.
Declaration
public Task CommitAsync(CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Threading.CancellationToken | cancellationToken | The token to monitor for cancellation requests. The default value is System.Threading.CancellationToken.None. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Dispose(Boolean)
Disposes the transaction, rolling it back if it is still pending.
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing |
Overrides
DisposeAsync()
Disposes the transaction, rolling it back if it is still pending.
Declaration
public ValueTask DisposeAsync()
Returns
Type | Description |
---|---|
ValueTask |
Release(String)
Releases a transaction from a pending savepoint state.
Declaration
public void Release(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the savepoint. |
ReleaseAsync(String, CancellationToken)
Releases a transaction from a pending savepoint state.
Declaration
public Task ReleaseAsync(string name, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the savepoint. |
System.Threading.CancellationToken | cancellationToken | The token to monitor for cancellation requests. The default value is System.Threading.CancellationToken.None. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Rollback()
Rolls back a transaction from a pending state.
Declaration
public override void Rollback()
Overrides
Rollback(String)
Rolls back a transaction from a pending savepoint state.
Declaration
public void Rollback(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the savepoint. |
RollbackAsync()
Rolls back a transaction from a pending state.
Declaration
public Task RollbackAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
RollbackAsync(String, CancellationToken)
Rolls back a transaction from a pending savepoint state.
Declaration
public Task RollbackAsync(string name, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the savepoint. |
System.Threading.CancellationToken | cancellationToken | The token to monitor for cancellation requests. The default value is System.Threading.CancellationToken.None. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
RollbackAsync(CancellationToken)
Rolls back a transaction from a pending state.
Declaration
public Task RollbackAsync(CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Threading.CancellationToken | cancellationToken | The token to monitor for cancellation requests. The default value is System.Threading.CancellationToken.None. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Save(String)
Creates a transaction save point.
Declaration
public void Save(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the savepoint. |
SaveAsync(String, CancellationToken)
Creates a transaction save point.
Declaration
public Task SaveAsync(string name, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the savepoint. |
System.Threading.CancellationToken | cancellationToken | The token to monitor for cancellation requests. The default value is System.Threading.CancellationToken.None. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |