Google.Cloud.Spanner.Data - Class KeySet (5.0.0-beta04)

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

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
Type Description
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
Type Description
bool

Keys

public IEnumerable<Key> Keys { get; }

The collection of specific keys to select.

Property Value
Type Description
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
Type Description
IEnumerableKeyRange

Methods

FromKeys(params Key[])

public static KeySet FromKeys(params Key[] keys)

Creates a new key set for a collection of keys.

Parameter
Name Description
keys Key

The keys to select

Returns
Type Description
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
Name Description
parameters SpannerParameterCollection

A parameter collection containing the values of the key

Returns
Type Description
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
Name Description
ranges KeyRange

The key ranges to select

Returns
Type Description
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
Name Description
builder SpannerConnectionStringBuilder

The SpannerConnectionStringBuilder instance used to derive default conversion options.

Returns
Type Description
string

A string that represents the current KeySet.