Class KeySet (3.15.1)

public sealed 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.

Inheritance

Object > KeySet

Namespace

Google.Cloud.Spanner.Data

Assembly

Google.Cloud.Spanner.Data.dll

Example

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

public static KeySet All { get; }

Returns a key set that selects all keys in the table or index.

Property Value
TypeDescription
KeySet

AllKeys

public bool AllKeys { get; }

True for key sets that select all keys in the table or index, and false for all other key sets.

Property Value
TypeDescription
Boolean

Keys

public IEnumerable<Key> Keys { get; }

The collection of specific keys to select.

Property Value
TypeDescription
IEnumerable<Key>

Ranges

public IEnumerable<KeyRange> Ranges { get; }

The list of key ranges to select. All rows that are in at least one of the key ranges will be selected.

Property Value
TypeDescription
IEnumerable<KeyRange>

Methods

FromKeys(Key[])

public static KeySet FromKeys(params Key[] keys)

Creates a new key set for a collection of keys.

Parameter
NameDescription
keysKey[]

The keys to select

Returns
TypeDescription
KeySet

A key set for a collection of keys

FromParameters(SpannerParameterCollection)

public static KeySet FromParameters(SpannerParameterCollection parameters)

Creates a new key set from a collection of parameters that represent exactly one key.

Parameter
NameDescription
parametersSpannerParameterCollection

A parameter collection containing the values of the key

Returns
TypeDescription
KeySet

A key set for one specific key

FromRanges(KeyRange[])

public static KeySet FromRanges(params KeyRange[] ranges)

Creates a new key set for a collection of key ranges.

Parameter
NameDescription
rangesKeyRange[]

The key ranges to select

Returns
TypeDescription
KeySet

A key set for a collection of key ranges

GetHashCode()

public override int GetHashCode()
Returns
TypeDescription
Int32
Overrides

ToString()

public override string ToString()
Returns
TypeDescription
String
Overrides