Google.Cloud.Spanner.Data - Class KeySet (4.3.0)

public sealed class KeySet

Reference documentation and code samples for the Google.Cloud.Spanner.Data 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

GoogleCloudGoogle.Cloud.SpannerData

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
bool

Keys

public IEnumerable<Key> Keys { get; }

The collection of specific keys to select.

Property Value
TypeDescription
IEnumerableKey

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
IEnumerableKeyRange

Methods

FromKeys(params 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(params 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

ToString(SpannerConnectionStringBuilder)

public string ToString(SpannerConnectionStringBuilder builder)

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.

Parameter
NameDescription
builderSpannerConnectionStringBuilder

The SpannerConnectionStringBuilder instance used to derive default conversion options.

Returns
TypeDescription
string

A string that represents the current KeySet.