Class KeySet
Immutable class that defines a set of keys to select from a table or index. KeySets are used for Read operations to specify the rows that should be returned by the read. A KeySet can be created from a set of individual keys or a set of key ranges. The All instance can be used for read operations that should return all rows.
Namespace: Google.Cloud.Spanner.Data
Assembly: Google.Cloud.Spanner.Data.dll
Syntax
public sealed class KeySet
Examples
Example usage:
using var cmd = connection.CreateReadCommand(
"MyTable",
ReadOptions.FromColumns("MyCol1", "MyCol2"),
KeySet.FromKeys(new Key("k1"), new Key("k2")));
using var reader = await cmd.ExecuteReaderAsync();
Properties
All
Returns a key set that selects all keys in the table or index.
Declaration
public static KeySet All { get; }
Property Value
Type | Description |
---|---|
KeySet |
AllKeys
True for key sets that select all keys in the table or index, and false for all other key sets.
Declaration
public bool AllKeys { get; }
Property Value
Type | Description |
---|---|
bool |
Keys
The collection of specific keys to select.
Declaration
public IEnumerable<Key> Keys { get; }
Property Value
Type | Description |
---|---|
IEnumerable<Key> |
Ranges
The list of key ranges to select. All rows that are in at least one of the key ranges will be selected.
Declaration
public IEnumerable<KeyRange> Ranges { get; }
Property Value
Type | Description |
---|---|
IEnumerable<KeyRange> |
Methods
FromKeys(params Key[])
Creates a new key set for a collection of keys.
Declaration
public static KeySet FromKeys(params Key[] keys)
Parameters
Type | Name | Description |
---|---|---|
Key[] | keys | The keys to select |
Returns
Type | Description |
---|---|
KeySet | A key set for a collection of keys |
FromParameters(SpannerParameterCollection)
Creates a new key set from a collection of parameters that represent exactly one key.
Declaration
public static KeySet FromParameters(SpannerParameterCollection parameters)
Parameters
Type | Name | Description |
---|---|---|
SpannerParameterCollection | parameters | A parameter collection containing the values of the key |
Returns
Type | Description |
---|---|
KeySet | A key set for one specific key |
FromRanges(params KeyRange[])
Creates a new key set for a collection of key ranges.
Declaration
public static KeySet FromRanges(params KeyRange[] ranges)
Parameters
Type | Name | Description |
---|---|---|
KeyRange[] | ranges | The key ranges to select |
Returns
Type | Description |
---|---|
KeySet | A key set for a collection of key ranges |
ToString(SpannerConnectionStringBuilder)
Returns the string representation of this KeySet using the type conversion options specified in SpannerConnectionStringBuilder. The string representation is only for diagnostic purposes and the implementation may change over time.
Declaration
public string ToString(SpannerConnectionStringBuilder builder)
Parameters
Type | Name | Description |
---|---|---|
SpannerConnectionStringBuilder | builder | The SpannerConnectionStringBuilder instance used to derive default conversion options. |
Returns
Type | Description |
---|---|
string | A string that represents the current KeySet. |