Class SpannerStruct
A struct parameter or returned value.
Implements
Namespace: Google.Cloud.Spanner.Data
Assembly: Google.Cloud.Spanner.Data.dll
Syntax
public sealed class SpannerStruct : IReadOnlyList<SpannerStruct.Field>, IReadOnlyCollection<SpannerStruct.Field>, IEnumerable<SpannerStruct.Field>, IEnumerable
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
Returns the number of fields currently in the struct.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
int |
Implements
this[int]
Returns the field at the given index.
Declaration
public SpannerStruct.Field this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
int | index | The index of the field to return |
Property Value
Type | Description |
---|---|
SpannerStruct.Field | The field at the given index |
Implements
Methods
Add(Field)
Adds a new field to the struct.
Declaration
public SpannerStruct.Field Add(SpannerStruct.Field field)
Parameters
Type | Name | Description |
---|---|---|
SpannerStruct.Field | field | The field to add. Must not be null. |
Returns
Type | Description |
---|---|
SpannerStruct.Field |
|
Add(string, SpannerDbType, object)
Adds a new field to the struct with the given name, type and value.
Declaration
public SpannerStruct.Field Add(string name, SpannerDbType type, object value)
Parameters
Type | Name | Description |
---|---|---|
string | name | 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. |
SpannerDbType | type | The type of the field. Must not be null. |
object | value | The value of the field. May be null. |
Returns
Type | Description |
---|---|
SpannerStruct.Field | The newly-added field. |
GetEnumerator()
Returns an enumerator that iterates through the collection.
Declaration
public IEnumerator<SpannerStruct.Field> GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<SpannerStruct.Field> | An enumerator that can be used to iterate through the collection. |
Implements
GetSpannerDbType()
Returns the full schema of this struct as a SpannerDbType.
Declaration
public SpannerDbType GetSpannerDbType()
Returns
Type | Description |
---|---|
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.