Search Results for

    Show / Hide Table of Contents

    Class NpgsqlTransaction

    Represents a transaction to be made in a PostgreSQL database. This class cannot be inherited.

    Inheritance
    Object
    MarshalByRefObject
    DbTransaction
    NpgsqlTransaction
    Implements
    IDbTransaction
    IDisposable
    IAsyncDisposable
    Inherited Members
    DbTransaction.Dispose()
    DbTransaction.IDbTransaction.Connection
    MarshalByRefObject.GetLifetimeService()
    MarshalByRefObject.InitializeLifetimeService()
    MarshalByRefObject.MemberwiseClone(Boolean)
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Object.ReferenceEquals(Object, Object)
    Object.ToString()
    Namespace: Npgsql
    Assembly: Npgsql.dll
    Syntax
    public sealed class NpgsqlTransaction : DbTransaction, IDbTransaction, IDisposable, IAsyncDisposable

    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
    DbConnection

    The NpgsqlConnection object associated with the transaction.

    Overrides
    DbTransaction.DbConnection

    IsolationLevel

    Specifies the isolation level for this transaction.

    Declaration
    public override IsolationLevel IsolationLevel { get; }
    Property Value
    Type Description
    IsolationLevel

    The isolation level for this transaction. The default is ReadCommitted.

    Overrides
    DbTransaction.IsolationLevel

    Methods

    Commit()

    Commits the database transaction.

    Declaration
    public override void Commit()
    Overrides
    DbTransaction.Commit()

    CommitAsync(CancellationToken)

    Commits the database transaction.

    Declaration
    public override Task CommitAsync(CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    CancellationToken cancellationToken

    An optional token to cancel the asynchronous operation. The default value is None.

    Returns
    Type Description
    Task
    Overrides
    DbTransaction.CommitAsync(CancellationToken)

    Dispose(Boolean)

    Disposes the transaction, rolling it back if it is still pending.

    Declaration
    protected override void Dispose(bool disposing)
    Parameters
    Type Name Description
    Boolean disposing
    Overrides
    DbTransaction.Dispose(Boolean)

    DisposeAsync()

    Disposes the transaction, rolling it back if it is still pending.

    Declaration
    public override ValueTask DisposeAsync()
    Returns
    Type Description
    ValueTask
    Overrides
    DbTransaction.DisposeAsync()

    Release(String)

    Releases a transaction from a pending savepoint state.

    Declaration
    public void Release(string name)
    Parameters
    Type Name Description
    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
    String name

    The name of the savepoint.

    CancellationToken cancellationToken

    An optional token to cancel the asynchronous operation. The default value is None.

    Returns
    Type Description
    Task

    Rollback()

    Rolls back a transaction from a pending state.

    Declaration
    public override void Rollback()
    Overrides
    DbTransaction.Rollback()

    Rollback(String)

    Rolls back a transaction from a pending savepoint state.

    Declaration
    public void Rollback(string name)
    Parameters
    Type Name Description
    String name

    The name of the savepoint.

    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
    String name

    The name of the savepoint.

    CancellationToken cancellationToken

    An optional token to cancel the asynchronous operation. The default value is None.

    Returns
    Type Description
    Task

    RollbackAsync(CancellationToken)

    Rolls back a transaction from a pending state.

    Declaration
    public override Task RollbackAsync(CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    CancellationToken cancellationToken

    An optional token to cancel the asynchronous operation. The default value is None.

    Returns
    Type Description
    Task
    Overrides
    DbTransaction.RollbackAsync(CancellationToken)

    Save(String)

    Creates a transaction save point.

    Declaration
    public void Save(string name)
    Parameters
    Type Name Description
    String name

    The 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.

    Declaration
    public Task SaveAsync(string name, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    String name

    The name of the savepoint.

    CancellationToken cancellationToken

    An optional token to cancel the asynchronous operation. The default value is None.

    Returns
    Type Description
    Task
    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.

    Implements

    System.Data.IDbTransaction
    System.IDisposable
    System.IAsyncDisposable
    In This Article
    Back to top © Copyright 2022 The Npgsql Development Team