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.
Implements
IReadOnlyListSpannerStructField, IReadOnlyCollectionSpannerStructField, IEnumerableSpannerStructField, IEnumerableNamespace
Google.Cloud.Spanner.DataAssembly
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 | |
---|---|
Type | Description |
int |
this[int]
public SpannerStruct.Field this[int index] { get; }
Returns the field at the given index.
Parameter | |
---|---|
Name | Description |
index | int The index of the field to return |
Property Value | |
---|---|
Type | Description |
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 | |
---|---|
Name | Description |
field | SpannerStructField The field to add. Must not be null. |
Returns | |
---|---|
Type | Description |
SpannerStructField |
|
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 | |
---|---|
Name | Description |
name | string 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. |
type | SpannerDbType The type of the field. Must not be null. |
value | object The value of the field. May be null. |
Returns | |
---|---|
Type | Description |
SpannerStructField | The newly-added field. |
GetEnumerator()
public IEnumerator<SpannerStruct.Field> GetEnumerator()
Returns an enumerator that iterates through the collection.
Returns | |
---|---|
Type | Description |
IEnumeratorSpannerStructField | An enumerator that can be used to iterate through the collection. |
GetSpannerDbType()
public SpannerDbType GetSpannerDbType()
Returns the full schema of this struct as a SpannerDbType.
Returns | |
---|---|
Type | Description |
SpannerDbType | The SpannerDbType representing the schema of this struct. |
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.