Couchbase .NET SDK | 3.7.2
Search Results for

    Show / Hide Table of Contents

    Class Transactions

    A class for running transactional operations against a Couchbase Cluster.

    Inheritance
    object
    Transactions
    Implements
    IDisposable
    IAsyncDisposable
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Couchbase.Client.Transactions
    Assembly: Couchbase.NetClient.dll
    Syntax
    public class Transactions : IDisposable, IAsyncDisposable

    Fields

    | Edit this page View Source

    OpRetryDelay

    A standard delay between retried operations.

    Declaration
    public static readonly TimeSpan OpRetryDelay
    Field Value
    Type Description
    TimeSpan

    Properties

    | Edit this page View Source

    Config

    Gets the TransactionsConfig to apply to all transaction runs from this instance.

    Declaration
    public TransactionsConfig Config { get; }
    Property Value
    Type Description
    TransactionsConfig

    Methods

    | Edit this page View Source

    Create(ICluster)

    Create a Transactions instance for running transactions against the specified Cluster.

    Declaration
    public static Transactions Create(ICluster cluster)
    Parameters
    Type Name Description
    ICluster cluster

    The cluster where your documents will be located.

    Returns
    Type Description
    Transactions

    A Transactions instance.

    Remarks

    The instance returned from this method should be kept for the lifetime of your application and used like a singleton per Couchbase cluster you will be accessing.

    | Edit this page View Source

    Create(ICluster, TransactionsConfig)

    Create a Transactions instance for running transactions against the specified Cluster.

    Declaration
    public static Transactions Create(ICluster cluster, TransactionsConfig config)
    Parameters
    Type Name Description
    ICluster cluster

    The cluster where your documents will be located.

    TransactionsConfig config

    The TransactionsConfig to use for all transactions against this cluster.

    Returns
    Type Description
    Transactions

    A Transactions instance.

    Remarks

    The instance returned from this method should be kept for the lifetime of your application and used like a singleton per Couchbase cluster you will be accessing.

    | Edit this page View Source

    Create(ICluster, TransactionsConfigBuilder)

    Create a Transactions instance for running transactions against the specified Cluster.

    Declaration
    public static Transactions Create(ICluster cluster, TransactionsConfigBuilder configBuilder)
    Parameters
    Type Name Description
    ICluster cluster

    The cluster where your documents will be located.

    TransactionsConfigBuilder configBuilder

    The TransactionsConfigBuilder to generate a TransactionsConfig to use for all transactions against this cluster.

    Returns
    Type Description
    Transactions

    A Transactions instance.

    Remarks

    The instance returned from this method should be kept for the lifetime of your application and used like a singleton per Couchbase cluster you will be accessing.

    | Edit this page View Source

    Dispose()

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

    DisposeAsync()

    Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

    Declaration
    public ValueTask DisposeAsync()
    Returns
    Type Description
    ValueTask
    | Edit this page View Source

    QueryAsync<T>(string, SingleQueryTransactionConfigBuilder?, IScope?)

    Run a single query as a transaction.

    Declaration
    public Task<SingleQueryTransactionResult<T>> QueryAsync<T>(string statement, SingleQueryTransactionConfigBuilder? config = null, IScope? scope = null)
    Parameters
    Type Name Description
    string statement

    The statement to execute.

    SingleQueryTransactionConfigBuilder config

    The configuration to use for this transaction.

    IScope scope

    The scope

    Returns
    Type Description
    Task<SingleQueryTransactionResult<T>>

    A SingleQueryTransactionResult<T> with the query results, if any.

    Type Parameters
    Name Description
    T

    The type of the result. Use object for queries with no results.

    | Edit this page View Source

    RunAsync(Func<AttemptContext, Task>)

    Run a transaction against the cluster.

    Declaration
    public Task<TransactionResult> RunAsync(Func<AttemptContext, Task> transactionLogic)
    Parameters
    Type Name Description
    Func<AttemptContext, Task> transactionLogic

    A func representing the transaction logic. All data operations should use the methods on the AttemptContext provided. Do not mix and match non-transactional data operations.

    Returns
    Type Description
    Task<TransactionResult>

    The result of the transaction.

    | Edit this page View Source

    RunAsync(Func<AttemptContext, Task>, PerTransactionConfig)

    Run a transaction against the cluster.

    Declaration
    public Task<TransactionResult> RunAsync(Func<AttemptContext, Task> transactionLogic, PerTransactionConfig perConfig)
    Parameters
    Type Name Description
    Func<AttemptContext, Task> transactionLogic

    A func representing the transaction logic. All data operations should use the methods on the AttemptContext provided. Do not mix and match non-transactional data operations.

    PerTransactionConfig perConfig

    A config with values unique to this specific transaction.

    Returns
    Type Description
    Task<TransactionResult>

    The result of the transaction.

    Implements

    IDisposable
    IAsyncDisposable

    Extension Methods

    Extensions.QueryAsync<T>(Transactions, string, Action<SingleQueryTransactionConfigBuilder>?, IScope?)
    • Edit this page
    • View Source
    In this article
    Back to top © 2025 Couchbase, Inc.