public sealed class KeySet : IMessage<KeySet>, IEquatable<KeySet>, IDeepCloneable<KeySet>, IBufferMessage, IMessage
Reference documentation and code samples for the Google Cloud Spanner v1 API class KeySet.
KeySet defines a collection of Cloud Spanner keys and/or key ranges. All
the keys are expected to be in the same table or index. The keys need
not be sorted in any particular way.
If the same key is specified multiple times in the set (for example
if two ranges, two keys, or a key and a range overlap), Cloud Spanner
behaves as if the key were only specified once.
For convenience all can be set to true to indicate that this
KeySet matches all keys in the table or index. Note that any keys
specified in keys or ranges are only yielded once.
A list of specific keys. Entries in keys should have exactly as
many elements as there are columns in the primary or index key
with which this KeySet is used. Individual key values are
encoded as described [here][google.spanner.v1.TypeCode].
[[["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 of the \u003ccode\u003eKeySet\u003c/code\u003e API for Google Cloud Spanner v1 is \u003ccode\u003e5.0.0-beta05\u003c/code\u003e, with multiple prior versions available.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eKeySet\u003c/code\u003e is a class used to define a collection of keys and/or key ranges within the Google Cloud Spanner database.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eKeySet\u003c/code\u003e can specify individual keys via the \u003ccode\u003eKeys\u003c/code\u003e property or ranges of keys through the \u003ccode\u003eRanges\u003c/code\u003e property.\u003c/p\u003e\n"],["\u003cp\u003eThe class \u003ccode\u003eKeySet\u003c/code\u003e implements \u003ccode\u003eIMessage\u003c/code\u003e, \u003ccode\u003eIEquatable<KeySet>\u003c/code\u003e, \u003ccode\u003eIDeepCloneable<KeySet>\u003c/code\u003e, and \u003ccode\u003eIBufferMessage\u003c/code\u003e interfaces.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eAll\u003c/code\u003e property within \u003ccode\u003eKeySet\u003c/code\u003e allows for selecting all keys within a given table or index.\u003c/p\u003e\n"]]],[],null,["# Google Cloud Spanner v1 API - Class KeySet (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.KeySet)\n- [5.0.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/5.0.0/Google.Cloud.Spanner.V1.KeySet)\n- [4.6.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.6.0/Google.Cloud.Spanner.V1.KeySet)\n- [4.5.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.5.0/Google.Cloud.Spanner.V1.KeySet)\n- [4.4.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.4.0/Google.Cloud.Spanner.V1.KeySet)\n- [4.3.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.3.0/Google.Cloud.Spanner.V1.KeySet)\n- [4.2.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.2.0/Google.Cloud.Spanner.V1.KeySet)\n- [4.1.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.1.0/Google.Cloud.Spanner.V1.KeySet)\n- [4.0.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.0.0/Google.Cloud.Spanner.V1.KeySet)\n- [3.15.1](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.15.1/Google.Cloud.Spanner.V1.KeySet)\n- [3.14.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.14.0/Google.Cloud.Spanner.V1.KeySet)\n- [3.13.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.13.0/Google.Cloud.Spanner.V1.KeySet)\n- [3.12.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.12.0/Google.Cloud.Spanner.V1.KeySet)\n- [3.11.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.11.0/Google.Cloud.Spanner.V1.KeySet)\n- [3.10.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.10.0/Google.Cloud.Spanner.V1.KeySet)\n- [3.9.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.9.0/Google.Cloud.Spanner.V1.KeySet)\n- [3.8.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.8.0/Google.Cloud.Spanner.V1.KeySet)\n- [3.7.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.7.0/Google.Cloud.Spanner.V1.KeySet)\n- [3.6.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.6.0/Google.Cloud.Spanner.V1.KeySet)\n- [3.5.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.5.0/Google.Cloud.Spanner.V1.KeySet) \n\n public sealed class KeySet : IMessage\u003cKeySet\u003e, IEquatable\u003cKeySet\u003e, IDeepCloneable\u003cKeySet\u003e, IBufferMessage, IMessage\n\nReference documentation and code samples for the Google Cloud Spanner v1 API class KeySet.\n\n`KeySet` defines a collection of Cloud Spanner keys and/or key ranges. All\nthe keys are expected to be in the same table or index. The keys need\nnot be sorted in any particular way.\n\nIf the same key is specified multiple times in the set (for example\nif two ranges, two keys, or a key and a range overlap), Cloud Spanner\nbehaves as if the key were only specified once. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e KeySet \n\nImplements\n----------\n\n[IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage-1.html)[KeySet](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.KeySet), [IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[KeySet](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.KeySet), [IDeepCloneable](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IDeepCloneable-1.html)[KeySet](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.KeySet), [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### KeySet()\n\n public KeySet()\n\n### KeySet(KeySet)\n\n public KeySet(KeySet other)\n\nProperties\n----------\n\n### All\n\n public bool All { get; set; }\n\nFor convenience `all` can be set to `true` to indicate that this\n`KeySet` matches all keys in the table or index. Note that any keys\nspecified in `keys` or `ranges` are only yielded once.\n\n### Keys\n\n public RepeatedField\u003cListValue\u003e Keys { get; }\n\nA list of specific keys. Entries in `keys` should have exactly as\nmany elements as there are columns in the primary or index key\nwith which this `KeySet` is used. Individual key values are\nencoded as described \\[here\\]\\[google.spanner.v1.TypeCode\\].\n\n### Ranges\n\n public RepeatedField\u003cKeyRange\u003e Ranges { get; }\n\nA list of key ranges. See \\[KeyRange\\]\\[google.spanner.v1.KeyRange\\] for more information about\nkey range specifications."]]