Mallard
Search Results for

    Show / Hide Table of Contents

    Struct DuckDbTransaction

    Controls a database transaction in DuckDB.

    Implements
    IDbTransaction
    IDisposable
    IEquatable<DuckDbTransaction>
    Inherited Members
    ValueType.ToString()
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: Mallard
    Assembly: Mallard.dll
    Syntax
    public readonly struct DuckDbTransaction : IDbTransaction, IDisposable, IEquatable<DuckDbTransaction>
    Remarks

    An instance is obtained by BeginTransaction(). It should be put as the subject of a using block in C#, and within that using block, statements may be submitted to the originating DuckDbConnection object.

    This object should not be accessed from multiple threads at the same time. (If that is done, exceptions will be thrown when attempting to commit or roll back the transaction.)

    This type is a value type only to avoid GC allocation. All of the transaction state is actually lives inside DuckDbConnection. (A DuckDB connection can only accept at most one transaction at once.)

    Properties

    | Edit this page View Source

    Connection

    The database connection that this transaction was created on.

    Declaration
    public DuckDbConnection Connection { get; }
    Property Value
    Type Description
    DuckDbConnection
    | Edit this page View Source

    IsolationLevel

    The isolation level of the database transaction.

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

    DuckDB only supports snapshot-level isolation (Snapshot and that is what this property always reports.

    Methods

    | Edit this page View Source

    Commit()

    Commits this database transaction.

    Declaration
    public void Commit()
    Remarks

    This transaction becomes inactive (same as its disposed state) once this method is called, whether it succeeds or fails.

    Exceptions
    Type Condition
    ObjectDisposedException

    The underlying connection has already been disposed (closed).

    InvalidOperationException

    This transaction cannot be committed because it is no longer active (e.g. it has already been committed or rolled back).

    DuckDbException

    There has been a database-level error in committing the transaction, e.g. another connection made changes to the database which causes conflict with the changes from this transaction.

    | Edit this page View Source

    Dispose()

    Disposes of the transaction, equivalent to rolling it back if it has not been committed or rolled back already.

    Declaration
    public void Dispose()
    | Edit this page View Source

    Equals(DuckDbTransaction)

    Whether this instance and the other instance refers to the same transaction on the same database.

    Declaration
    public bool Equals(DuckDbTransaction other)
    Parameters
    Type Name Description
    DuckDbTransaction other
    Returns
    Type Description
    bool
    | Edit this page View Source

    Equals(object?)

    Indicates whether this instance and a specified object are equal.

    Declaration
    public override bool Equals(object? obj)
    Parameters
    Type Name Description
    object obj

    The object to compare with the current instance.

    Returns
    Type Description
    bool

    true if obj and this instance are the same type and represent the same value; otherwise, false.

    Overrides
    ValueType.Equals(object)
    | Edit this page View Source

    GetHashCode()

    Returns the hash code for this instance.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int

    A 32-bit signed integer that is the hash code for this instance.

    Overrides
    ValueType.GetHashCode()
    | Edit this page View Source

    Rollback()

    Rolls back changes from this database transaction.

    Declaration
    public void Rollback()
    Remarks

    This transaction becomes inactive (same as its disposed state) once this method is called, whether it succeeds or fails.

    Exceptions
    Type Condition
    ObjectDisposedException

    The underlying connection has already been disposed (closed).

    InvalidOperationException

    This transaction cannot be rolled back because it is no longer active (e.g. it has already been committed or rolled back).

    DuckDbException

    There has been a database-level error in rolling back the transaction.

    Implements

    IDbTransaction
    IDisposable
    IEquatable<T>
    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX