public sealed class SpannerDbType
Reference documentation and code samples for the Google.Cloud.Spanner.Data class SpannerDbType.
Represents a Type that can be stored in a Spanner column or returned from a query.
Namespace
Google.Cloud.Spanner.DataAssembly
Google.Cloud.Spanner.Data.dll
Properties
Bool
public static SpannerDbType Bool { get; }
true
or false
.
Property Value | |
---|---|
Type | Description |
SpannerDbType |
Bytes
public static SpannerDbType Bytes { get; }
A byte array (byte[]).
Property Value | |
---|---|
Type | Description |
SpannerDbType |
Date
public static SpannerDbType Date { get; }
A Date.
Property Value | |
---|---|
Type | Description |
SpannerDbType |
DbType
public DbType DbType { get; }
The corresponding DbType for this Cloud Spanner type.
Property Value | |
---|---|
Type | Description |
DbType |
DefaultClrType
public Type DefaultClrType { get; }
The default Type for this Cloud Spanner type.
Property Value | |
---|---|
Type | Description |
Type |
Float32
public static SpannerDbType Float32 { get; }
32 bit floating point number.
Property Value | |
---|---|
Type | Description |
SpannerDbType |
Float64
public static SpannerDbType Float64 { get; }
64 bit floating point number. This is equivalent to Float8 in the PostgreSQL dialect.
Property Value | |
---|---|
Type | Description |
SpannerDbType |
Int64
public static SpannerDbType Int64 { get; }
64 bit signed integer.
Property Value | |
---|---|
Type | Description |
SpannerDbType |
Json
public static SpannerDbType Json { get; }
A JSON-formatted string as described in RFC 7159.
Property Value | |
---|---|
Type | Description |
SpannerDbType |
Numeric
public static SpannerDbType Numeric { get; }
A fixed-point number with 29 decimal digits of precision in the whole component and 9 decimal digits of precision in the fractional component.
Property Value | |
---|---|
Type | Description |
SpannerDbType |
PgJsonb
public static SpannerDbType PgJsonb { get; }
Representation of PostgreSQL JSONB type.
Property Value | |
---|---|
Type | Description |
SpannerDbType |
PgNumeric
public static SpannerDbType PgNumeric { get; }
Representation of PostgreSQL numeric type. The PostgreSQL numeric type has max precision of 147,455 and a max scale of 16383.
Property Value | |
---|---|
Type | Description |
SpannerDbType |
PgOid
public static SpannerDbType PgOid { get; }
Representation of PostgreSQL OID type.
Property Value | |
---|---|
Type | Description |
SpannerDbType |
Size
public int? Size { get; }
The size of the Type, if set.
Property Value | |
---|---|
Type | Description |
int |
String
public static SpannerDbType String { get; }
A string.
Property Value | |
---|---|
Type | Description |
SpannerDbType |
Timestamp
public static SpannerDbType Timestamp { get; }
Date and Time.
Property Value | |
---|---|
Type | Description |
SpannerDbType |
Unspecified
public static SpannerDbType Unspecified { get; }
Not specified.
Property Value | |
---|---|
Type | Description |
SpannerDbType |
Methods
ArrayOf(SpannerDbType)
public static SpannerDbType ArrayOf(SpannerDbType elementType)
Creates an array of the specified type. This can be done on any arbitrary SpannerDbType.
You may use any type that implements IEnumerable as a source for the array. The type of each
item is determined by elementType
.
When calling GetFieldValue<T>(string) the default type
is List<T>. You may, however, specify any type that implements IList which
has a default constructor.
Parameter | |
---|---|
Name | Description |
elementType |
SpannerDbType The type of each item in the array. |
Returns | |
---|---|
Type | Description |
SpannerDbType |
FromClrType(Type)
public static SpannerDbType FromClrType(Type type)
Returns a SpannerDbType given a ClrType. If the type cannot be determined, Unspecified is returned.
Parameter | |
---|---|
Name | Description |
type |
Type The clrType to convert. |
Returns | |
---|---|
Type | Description |
SpannerDbType |
The best Spanner representation of the given Clr Type. |
GetHashCode()
public override int GetHashCode()
Serves as the default hash function.
Returns | |
---|---|
Type | Description |
int |
A hash code for the current object. |
ToString()
public override string ToString()
Returns a string that represents the current object.
Returns | |
---|---|
Type | Description |
string |
A string that represents the current object. |
TryParse(string, out SpannerDbType)
public static bool TryParse(string spannerType, out SpannerDbType spannerDbType)
Given a string representation, returns an instance of SpannerDbType.
Parameters | |
---|---|
Name | Description |
spannerType |
string A string representation of a SpannerDbType. See ToString(). |
spannerDbType |
SpannerDbType If parsing was successful, then an instance of SpannerDbType. Otherwise null. |
Returns | |
---|---|
Type | Description |
bool |
True if the parse was successful. |
WithSize(int)
public SpannerDbType WithSize(int size)
Returns a clone of this type with the specified size constraint. Only valid on Google.Cloud.Spanner.V1.TypeCode.String and Google.Cloud.Spanner.V1.TypeCode.Bytes
Parameter | |
---|---|
Name | Description |
size |
int Represents the number of characters (for Google.Cloud.Spanner.V1.TypeCode.String) or bytes (for Google.Cloud.Spanner.V1.TypeCode.Bytes) |
Returns | |
---|---|
Type | Description |
SpannerDbType |
A new instance of SpannerDbType with the same TypeCode and new size. |