Google.Cloud.Spanner.Data - Class SpannerStruct (4.4.0)

public sealed class SpannerStruct : IReadOnlyList<SpannerStruct.Field>, IReadOnlyCollection<SpannerStruct.Field>, IEnumerable<SpannerStruct.Field>, IEnumerable

Reference documentation and code samples for the Google.Cloud.Spanner.Data class SpannerStruct.

A struct parameter or returned value.

Inheritance

object > SpannerStruct

Namespace

GoogleCloudGoogle.Cloud.SpannerData

Assembly

Google.Cloud.Spanner.Data.dll

Remarks

A Spanner struct isn't exactly the same as a Google Protobuf struct:

  • Field names are optional
  • Field names do not have to be unique

Properties

Count

public int Count { get; }

Returns the number of fields currently in the struct.

Property Value
TypeDescription
int

this[int]

public SpannerStruct.Field this[int index] { get; }

Returns the field at the given index.

Parameter
NameDescription
indexint

The index of the field to return

Property Value
TypeDescription
SpannerStructField

The field at the given index

Methods

Add(Field)

public SpannerStruct.Field Add(SpannerStruct.Field field)

Adds a new field to the struct.

Parameter
NameDescription
fieldSpannerStructField

The field to add. Must not be null.

Returns
TypeDescription
SpannerStructField

field for convenience

Add(string, SpannerDbType, object)

public SpannerStruct.Field Add(string name, SpannerDbType type, object value)

Adds a new field to the struct with the given name, type and value.

Parameters
NameDescription
namestring

The name of the field. May be null, and does not need to be unique within the struct. If the value is null, the SpannerStruct.Field value added will have an empty string for the name.

typeSpannerDbType

The type of the field. Must not be null.

valueobject

The value of the field. May be null.

Returns
TypeDescription
SpannerStructField

The newly-added field.

GetEnumerator()

public IEnumerator<SpannerStruct.Field> GetEnumerator()
Returns
TypeDescription
IEnumeratorSpannerStructField

GetSpannerDbType()

public SpannerDbType GetSpannerDbType()

Returns the full schema of this struct as a SpannerDbType.

Returns
TypeDescription
SpannerDbType

The SpannerDbType representing the schema of this struct.

Remarks

The returned object reflects the current fields in the struct. If more fields are added later, those changes will not be visible via the returned value. Instead, this method should be called again obtain the up-to-date schema.