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.
As opposed to 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.
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() and similar overloads.
For command execution priority, use Priority.
This value will be ignored by read-only transactions.
The wait time, in seconds, before terminating the attempt to Commit()
or 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.
public DisposeBehavior DisposeBehavior { get; set; }
Specifies how resources are treated when Dispose(bool) is called.
Defaults to Default. For a pooled transaction,
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 all transactional resource will be closed.
A detached transaction must have one process choose CloseResources
to avoid leaks of transactional resources.
Changes to this value will be ignored after the transaction has been disposed.
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.
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, 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 and 500ms.
Cannot be modified after commit or rollback has been called on the transaction.
The transaction tag to use for 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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["\u003cp\u003eThis page provides reference documentation for the \u003ccode\u003eSpannerTransactionOptions\u003c/code\u003e class within the \u003ccode\u003eGoogle.Cloud.Spanner.Data\u003c/code\u003e namespace in .NET.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eSpannerTransactionOptions\u003c/code\u003e class allows users to specify options for a transaction after it has been created, usually before committing or executing the first transactional statement.\u003c/p\u003e\n"],["\u003cp\u003eThe latest version of the \u003ccode\u003eSpannerTransactionOptions\u003c/code\u003e class is \u003ccode\u003e5.0.0-beta05\u003c/code\u003e, with previous versions available dating back to version \u003ccode\u003e3.5.0\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eMaxCommitDelay\u003c/code\u003e property of \u003ccode\u003eSpannerTransactionOptions\u003c/code\u003e allows configuration of commit batching, impacting throughput and latency, and can range from zero to 500 milliseconds.\u003c/p\u003e\n"],["\u003cp\u003eInstances of \u003ccode\u003eSpannerTransactionOptions\u003c/code\u003e are mutable, which is useful in ORM or similar implementations that depend on ADO.NET.\u003c/p\u003e\n"]]],[],null,["# Google.Cloud.Spanner.Data - Class SpannerTransactionOptions (5.1.0)\n\nVersion latestkeyboard_arrow_down\n\n- [5.1.0 (latest)](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerTransactionOptions)\n- [5.0.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/5.0.0/Google.Cloud.Spanner.Data.SpannerTransactionOptions)\n- [4.6.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/4.6.0/Google.Cloud.Spanner.Data.SpannerTransactionOptions)\n- [4.5.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/4.5.0/Google.Cloud.Spanner.Data.SpannerTransactionOptions)\n- [4.4.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/4.4.0/Google.Cloud.Spanner.Data.SpannerTransactionOptions)\n- [4.3.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/4.3.0/Google.Cloud.Spanner.Data.SpannerTransactionOptions)\n- [4.2.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/4.2.0/Google.Cloud.Spanner.Data.SpannerTransactionOptions)\n- [4.1.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/4.1.0/Google.Cloud.Spanner.Data.SpannerTransactionOptions)\n- [4.0.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/4.0.0/Google.Cloud.Spanner.Data.SpannerTransactionOptions)\n- [3.15.1](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.15.1/Google.Cloud.Spanner.Data.SpannerTransactionOptions)\n- [3.14.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.14.0/Google.Cloud.Spanner.Data.SpannerTransactionOptions)\n- [3.13.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.13.0/Google.Cloud.Spanner.Data.SpannerTransactionOptions)\n- [3.12.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.12.0/Google.Cloud.Spanner.Data.SpannerTransactionOptions)\n- [3.11.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.11.0/Google.Cloud.Spanner.Data.SpannerTransactionOptions)\n- [3.10.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.10.0/Google.Cloud.Spanner.Data.SpannerTransactionOptions)\n- [3.9.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.9.0/Google.Cloud.Spanner.Data.SpannerTransactionOptions)\n- [3.8.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.8.0/Google.Cloud.Spanner.Data.SpannerTransactionOptions)\n- [3.7.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.7.0/Google.Cloud.Spanner.Data.SpannerTransactionOptions)\n- [3.6.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.6.0/Google.Cloud.Spanner.Data.SpannerTransactionOptions)\n- [3.5.0](/dotnet/docs/reference/Google.Cloud.Spanner.Data/3.5.0/Google.Cloud.Spanner.Data.SpannerTransactionOptions) \n\n public sealed class SpannerTransactionOptions\n\nReference documentation and code samples for the Google.Cloud.Spanner.Data class SpannerTransactionOptions.\n\nOptions that may be applied to a transaction after creation, usually before committing the transaction\nor before executing the first transactional statement. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e SpannerTransactionOptions \n\nInherited Members\n-----------------\n\n[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) \n[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\nNamespace\n---------\n\n[Google.Cloud.Spanner.Data](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data)\n\nAssembly\n--------\n\nGoogle.Cloud.Spanner.Data.dll\n\nRemarks\n-------\n\nAs opposed to [SpannerTransactionCreationOptions](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerTransactionCreationOptions), instances of this class are mutable.\nThis is useful for ORM and similar implementations that depend on ADO.NET for transaction and command\ncreation, which does not know about these Spanner specific options. These implementations may still\naccess transaction and commands after creation and change these options.\n\nConstructors\n------------\n\n### SpannerTransactionOptions()\n\n public SpannerTransactionOptions()\n\nCreates an instance of [SpannerTransactionOptions](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerTransactionOptions) with default values.\n\n### SpannerTransactionOptions(SpannerTransactionOptions)\n\n public SpannerTransactionOptions(SpannerTransactionOptions other)\n\nCreates an instance of [SpannerTransactionOptions](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerTransactionOptions) with the same values as `other`.\n\nProperties\n----------\n\n### CommitPriority\n\n public Priority? CommitPriority { get; set; }\n\nThe priority to use for the [Commit()](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerTransaction#Google_Cloud_Spanner_Data_SpannerTransaction_Commit) and similar overloads.\nFor command execution priority, use [Priority](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerCommand#Google_Cloud_Spanner_Data_SpannerCommand_Priority).\nThis value will be ignored by read-only transactions.\n\n### CommitTimeout\n\n public int? CommitTimeout { get; set; }\n\nThe wait time, in seconds, before terminating the attempt to [Commit()](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerTransaction#Google_Cloud_Spanner_Data_SpannerTransaction_Commit)\nor [Rollback()](/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\nusing these options will default to the commit timeout defined on its connection string.\nA value of '0' normally indicates that no timeout should be used (wait an infinite amount of time).\nHowever, if you specify AllowImmediateTimeouts=true in the connection string, '0' will cause a timeout\nthat expires immediately. This is normally used only for testing purposes.\n\n### DisposeBehavior\n\n public DisposeBehavior DisposeBehavior { get; set; }\n\nSpecifies how resources are treated when [Dispose(bool)](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerTransaction#Google_Cloud_Spanner_Data_SpannerTransaction_Dispose_System_Boolean_) is called.\nDefaults to [Default](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.DisposeBehavior#Google_Cloud_Spanner_Data_DisposeBehavior_Default). For a pooled transaction,\n[Default](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.DisposeBehavior#Google_Cloud_Spanner_Data_DisposeBehavior_Default) will cause transactional resources\nto be sent back into a shared pool for re-use.\nFor a detached transaction the default behaviour is to do nothing with transactional resources.\nIf set to [CloseResources](/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.\nA detached transaction must have one process choose [CloseResources](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.DisposeBehavior#Google_Cloud_Spanner_Data_DisposeBehavior_CloseResources)\nto avoid leaks of transactional resources.\nChanges to this value will be ignored after the transaction has been disposed.\n\n### LogCommitStats\n\n public bool? LogCommitStats { get; set; }\n\nSpecifies whether this transaction should request commit statistics from the backend\nand log these. If unset, the value set on the SpannerConnection\nof this transaction will be used.\n\n### MaxCommitDelay\n\n public TimeSpan? MaxCommitDelay { get; set; }\n\nThe maximum amount of time the commit may be delayed server side for batching with other commits.\nThe bigger the delay, the better the throughput (QPS), but at the expense of commit latency.\nIf set to [Zero](https://learn.microsoft.com/dotnet/api/system.timespan.zero), commit batching is disabled.\nMay be null, in which case commits will continue to be batched as they had been before this configuration\noption was made available to Spanner API consumers.\nMay be set to any value between [Zero](https://learn.microsoft.com/dotnet/api/system.timespan.zero) and 500ms.\nCannot be modified after commit or rollback has been called on the transaction.\n\n### Tag\n\n public string Tag { get; set; }\n\nThe transaction tag to use for [SpannerTransaction](/dotnet/docs/reference/Google.Cloud.Spanner.Data/latest/Google.Cloud.Spanner.Data.SpannerTransaction)\nThis value will be ignored by read-only transactions.\nChanges to this value will be ignored by the transaction after it has executed statements."]]