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
    NpgsqlTransaction
    Namespace: Npgsql
    Assembly: Npgsql.dll
    Syntax
    public sealed class NpgsqlTransaction : DbTransaction

    Properties

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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 .

    | Improve this Doc View Source

    SupportsSavepoints

    Indicates whether this transaction supports database savepoints.

    Declaration
    public bool SupportsSavepoints { get; }
    Property Value
    Type Description
    bool

    Methods

    | Improve this Doc View Source

    Commit()

    Commits the database transaction.

    Declaration
    public override void Commit()
    | Improve this Doc View Source

    CommitAsync(CancellationToken)

    Commits the database transaction.

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

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

    Returns
    Type Description
    Task
    | Improve this Doc View Source

    Dispose(bool)

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

    Declaration
    protected override void Dispose(bool disposing)
    Parameters
    Type Name Description
    bool disposing
    | Improve this Doc View Source

    DisposeAsync()

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

    Declaration
    public override ValueTask DisposeAsync()
    Returns
    Type Description
    ValueTask
    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    ReleaseAsync(string, CancellationToken)

    Releases a transaction from a pending savepoint state.

    Declaration
    public Task ReleaseAsync(string name, CancellationToken cancellationToken = null)
    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 .

    Returns
    Type Description
    Task
    | Improve this Doc View Source

    Rollback()

    Rolls back a transaction from a pending state.

    Declaration
    public override void Rollback()
    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    RollbackAsync(CancellationToken)

    Rolls back a transaction from a pending state.

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

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

    Returns
    Type Description
    Task
    | Improve this Doc View Source

    RollbackAsync(string, CancellationToken)

    Rolls back a transaction from a pending savepoint state.

    Declaration
    public Task RollbackAsync(string name, CancellationToken cancellationToken = null)
    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 .

    Returns
    Type Description
    Task
    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    SaveAsync(string, CancellationToken)

    Creates a transaction save point.

    Declaration
    public Task SaveAsync(string name, CancellationToken cancellationToken = null)
    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 .

    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.

    • Improve this Doc
    • View Source
    In This Article
    Back to top © Copyright 2023 The Npgsql Development Team