# Google.Cloud.Spanner.Data - Class SpannerTransactionOptions (5.13.0-beta07)

5.13.0-beta07 5.13.0-beta06 5.12.0 (latest) 5.11.0 5.10.0 5.9.0 5.8.0 5.7.0 5.6.0 5.5.0 5.4.0 5.3.0 5.2.0 5.1.0 5.0.0 4.6.0 4.5.0 4.4.0 4.3.0 4.2.0 4.1.0 4.0.0 3.15.1 3.14.0 3.13.0 3.12.0 3.11.0 3.10.0 3.9.0 3.8.0 3.7.0 3.6.0 3.5.0

    public sealed class SpannerTransactionOptions

Reference documentation and code samples for the Google.Cloud.Spanner.Data class SpannerTransactionOptions.

Options that may be applied to a transaction after creation, usually before committing the transaction
or before executing the first transactional statement.

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> SpannerTransactionOptions

## Inherited Members

[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Namespace

[Google.Cloud.Spanner.Data](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data)

## Assembly

Google.Cloud.Spanner.Data.dll

## Remarks

As opposed to [SpannerTransactionCreationOptions](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerTransactionCreationOptions), instances of this class are mutable.
This is useful for ORM and similar implementations that depend on ADO.NET for transaction and command
creation, which does not know about these Spanner specific options. These implementations may still
access transaction and commands after creation and change these options.

## Constructors

### SpannerTransactionOptions()

    public SpannerTransactionOptions()

Creates an instance of [SpannerTransactionOptions](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerTransactionOptions) with default values.

### SpannerTransactionOptions(SpannerTransactionOptions)

    public SpannerTransactionOptions(SpannerTransactionOptions other)

Creates an instance of [SpannerTransactionOptions](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerTransactionOptions) with the same values as `other`.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `other` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerTransactionOptions` The options to create this instance from. Must not be null. |

## Properties

### CommitPriority

    public Priority? CommitPriority { get; set; }

The priority to use for the [Commit()](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerTransaction#Google_Cloud_Spanner_Data_SpannerTransaction_Commit) and similar overloads.
For command execution priority, use [Priority](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerCommand#Google_Cloud_Spanner_Data_SpannerCommand_Priority).
This value will be ignored by read-only transactions.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.Priority` |   |

### CommitTimeout

    public int? CommitTimeout { get; set; }

The wait time, in seconds, before terminating the attempt to [Commit()](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerTransaction#Google_Cloud_Spanner_Data_SpannerTransaction_Commit)
or [Rollback()](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerTransaction#Google_Cloud_Spanner_Data_SpannerTransaction_Rollback) and generating an error. May be null, in which case, a transaction
using these options will default to the commit timeout defined on its connection string.
A value of '0' normally indicates that no timeout should be used (wait an infinite amount of time).
However, if you specify AllowImmediateTimeouts=true in the connection string, '0' will cause a timeout
that expires immediately. This is normally used only for testing purposes.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.int32` |   |

### DisposeBehavior

    public DisposeBehavior DisposeBehavior { get; set; }

Specifies how resources are treated when [Dispose(bool)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerTransaction#Google_Cloud_Spanner_Data_SpannerTransaction_Dispose_System_Boolean_) is called.
Defaults to [Default](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.DisposeBehavior#Google_Cloud_Spanner_Data_DisposeBehavior_Default). For a pooled transaction,
[Default](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.DisposeBehavior#Google_Cloud_Spanner_Data_DisposeBehavior_Default) will cause transactional resources
to be sent back into a shared pool for re-use.
For a detached transaction the default behaviour is to do nothing with transactional resources.
If set to [CloseResources](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.DisposeBehavior#Google_Cloud_Spanner_Data_DisposeBehavior_CloseResources) all transactional resource will be closed.
A detached transaction must have one process choose [CloseResources](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.DisposeBehavior#Google_Cloud_Spanner_Data_DisposeBehavior_CloseResources)
to avoid leaks of transactional resources.
Changes to this value will be ignored after the transaction has been disposed.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.DisposeBehavior` |   |

### LogCommitStats

    public bool? LogCommitStats { get; set; }

Specifies whether this transaction should request commit statistics from the backend
and log these. If unset, the value set on the SpannerConnection
of this transaction will be used.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.boolean` |   |

### MaxCommitDelay

    public TimeSpan? MaxCommitDelay { get; set; }

The maximum amount of time the commit may be delayed server side for batching with other commits.
The bigger the delay, the better the throughput (QPS), but at the expense of commit latency.
If set to [Zero](https://learn.microsoft.com/dotnet/api/system.timespan.zero), commit batching is disabled.
May be null, in which case commits will continue to be batched as they had been before this configuration
option was made available to Spanner API consumers.
May be set to any value between [Zero](https://learn.microsoft.com/dotnet/api/system.timespan.zero) and 500ms.
Cannot be modified after commit or rollback has been called on the transaction.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.timespan` |   |

### Tag

    public string Tag { get; set; }

The transaction tag to use for [SpannerTransaction](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerTransaction)
This value will be ignored by read-only transactions.
Changes to this value will be ignored by the transaction after it has executed statements.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` |   |