public sealed class TransactionSelector : IMessage<TransactionSelector>, IEquatable<TransactionSelector>, IDeepCloneable<TransactionSelector>, IBufferMessage, IMessage
Reference documentation and code samples for the Google Cloud Spanner v1 API class TransactionSelector.
This message is used to select the transaction in which a
[Read][google.spanner.v1.Spanner.Read] or
[ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] call runs.
See [TransactionOptions][google.spanner.v1.TransactionOptions] for more
information about transactions.
Begin a new transaction and execute this read or SQL query in
it. The transaction ID of the new transaction is returned in
[ResultSetMetadata.transaction][google.spanner.v1.ResultSetMetadata.transaction],
which is a [Transaction][google.spanner.v1.Transaction].
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["\u003cp\u003eThe latest version available for the \u003ccode\u003eTransactionSelector\u003c/code\u003e class in the Google Cloud Spanner v1 API is 5.0.0-beta05.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eTransactionSelector\u003c/code\u003e class is used to determine the transaction context for \u003ccode\u003eRead\u003c/code\u003e or \u003ccode\u003eExecuteSql\u003c/code\u003e operations within the Google Cloud Spanner v1 API.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eTransactionSelector\u003c/code\u003e implements multiple interfaces including \u003ccode\u003eIMessage\u003c/code\u003e, \u003ccode\u003eIEquatable\u003c/code\u003e, \u003ccode\u003eIDeepCloneable\u003c/code\u003e, and \u003ccode\u003eIBufferMessage\u003c/code\u003e, which provides features for message handling, comparison, cloning and buffering.\u003c/p\u003e\n"],["\u003cp\u003eThis class allows you to choose between starting a new transaction, using an existing one, or performing a single-use transaction, which is ideal for single SQL query executions.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eTransactionSelector\u003c/code\u003e class offers properties like \u003ccode\u003eBegin\u003c/code\u003e, \u003ccode\u003eId\u003c/code\u003e, and \u003ccode\u003eSingleUse\u003c/code\u003e to manage transaction options and a \u003ccode\u003eSelectorCase\u003c/code\u003e to manage the selection of what transaction is used.\u003c/p\u003e\n"]]],[],null,["# Google Cloud Spanner v1 API - Class TransactionSelector (5.1.0)\n\nVersion latestkeyboard_arrow_down\n\n- [5.1.0 (latest)](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.TransactionSelector)\n- [5.0.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/5.0.0/Google.Cloud.Spanner.V1.TransactionSelector)\n- [4.6.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.6.0/Google.Cloud.Spanner.V1.TransactionSelector)\n- [4.5.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.5.0/Google.Cloud.Spanner.V1.TransactionSelector)\n- [4.4.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.4.0/Google.Cloud.Spanner.V1.TransactionSelector)\n- [4.3.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.3.0/Google.Cloud.Spanner.V1.TransactionSelector)\n- [4.2.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.2.0/Google.Cloud.Spanner.V1.TransactionSelector)\n- [4.1.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.1.0/Google.Cloud.Spanner.V1.TransactionSelector)\n- [4.0.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.0.0/Google.Cloud.Spanner.V1.TransactionSelector)\n- [3.15.1](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.15.1/Google.Cloud.Spanner.V1.TransactionSelector)\n- [3.14.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.14.0/Google.Cloud.Spanner.V1.TransactionSelector)\n- [3.13.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.13.0/Google.Cloud.Spanner.V1.TransactionSelector)\n- [3.12.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.12.0/Google.Cloud.Spanner.V1.TransactionSelector)\n- [3.11.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.11.0/Google.Cloud.Spanner.V1.TransactionSelector)\n- [3.10.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.10.0/Google.Cloud.Spanner.V1.TransactionSelector)\n- [3.9.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.9.0/Google.Cloud.Spanner.V1.TransactionSelector)\n- [3.8.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.8.0/Google.Cloud.Spanner.V1.TransactionSelector)\n- [3.7.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.7.0/Google.Cloud.Spanner.V1.TransactionSelector)\n- [3.6.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.6.0/Google.Cloud.Spanner.V1.TransactionSelector)\n- [3.5.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.5.0/Google.Cloud.Spanner.V1.TransactionSelector) \n\n public sealed class TransactionSelector : IMessage\u003cTransactionSelector\u003e, IEquatable\u003cTransactionSelector\u003e, IDeepCloneable\u003cTransactionSelector\u003e, IBufferMessage, IMessage\n\nReference documentation and code samples for the Google Cloud Spanner v1 API class TransactionSelector.\n\nThis message is used to select the transaction in which a\n\\[Read\\]\\[google.spanner.v1.Spanner.Read\\] or\n\\[ExecuteSql\\]\\[google.spanner.v1.Spanner.ExecuteSql\\] call runs.\n\nSee \\[TransactionOptions\\]\\[google.spanner.v1.TransactionOptions\\] for more\ninformation about transactions. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e TransactionSelector \n\nImplements\n----------\n\n[IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage-1.html)[TransactionSelector](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.TransactionSelector), [IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[TransactionSelector](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.TransactionSelector), [IDeepCloneable](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IDeepCloneable-1.html)[TransactionSelector](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.TransactionSelector), [IBufferMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IBufferMessage.html), [IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage.html) \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.V1](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1)\n\nAssembly\n--------\n\nGoogle.Cloud.Spanner.V1.dll\n\nConstructors\n------------\n\n### TransactionSelector()\n\n public TransactionSelector()\n\n### TransactionSelector(TransactionSelector)\n\n public TransactionSelector(TransactionSelector other)\n\nProperties\n----------\n\n### Begin\n\n public TransactionOptions Begin { get; set; }\n\nBegin a new transaction and execute this read or SQL query in\nit. The transaction ID of the new transaction is returned in\n\\[ResultSetMetadata.transaction\\]\\[google.spanner.v1.ResultSetMetadata.transaction\\],\nwhich is a \\[Transaction\\]\\[google.spanner.v1.Transaction\\].\n\n### HasId\n\n public bool HasId { get; }\n\nGets whether the \"id\" field is set\n\n### Id\n\n public ByteString Id { get; set; }\n\nExecute the read or SQL query in a previously-started transaction.\n\n### SelectorCase\n\n public TransactionSelector.SelectorOneofCase SelectorCase { get; }\n\n### SingleUse\n\n public TransactionOptions SingleUse { get; set; }\n\nExecute the read or SQL query in a temporary transaction.\nThis is the most efficient way to execute a transaction that\nconsists of a single SQL query."]]