Class SpannerDataReader (4.0.0)

public sealed class SpannerDataReader : DbDataReader, IEnumerable, IDataReader, IDataRecord, IDisposable, IAsyncDisposable

Reads a forward-only stream of rows from a data source.

Inheritance

Object > MarshalByRefObject > DbDataReader > SpannerDataReader

Namespace

Google.Cloud.Spanner.Data

Assembly

Google.Cloud.Spanner.Data.dll

Properties

Depth

public override int Depth { get; }
Property Value
Type Description
Int32
Overrides

FieldCount

public override int FieldCount { get; }
Property Value
Type Description
Int32
Overrides

HasRows

public override bool HasRows { get; }

Gets a value that indicates whether the SpannerDataReader contains one or more rows. If any rows have been read, this will continue to return true even when there are no more rows.

Property Value
Type Description
Boolean
Overrides

IsClosed

public override bool IsClosed { get; }
Property Value
Type Description
Boolean
Overrides

Item[Int32]

public override object this[int i] { get; }
Parameter
Name Description
i Int32
Property Value
Type Description
Object
Overrides

Item[String]

public override object this[string name] { get; }
Parameter
Name Description
name String
Property Value
Type Description
Object
Overrides

RecordsAffected

public override int RecordsAffected { get; }
Property Value
Type Description
Int32
Overrides

Methods

Close()

public override void Close()
Overrides

Dispose(Boolean)

protected override void Dispose(bool disposing)
Parameter
Name Description
disposing Boolean
Overrides

GetBoolean(Int32)

public override bool GetBoolean(int i)
Parameter
Name Description
i Int32
Returns
Type Description
Boolean
Overrides

GetByte(Int32)

public override byte GetByte(int i)
Parameter
Name Description
i Int32
Returns
Type Description
Byte
Overrides

GetBytes(Int32, Int64, Byte[], Int32, Int32)

public override long GetBytes(int ordinal, long fieldOffset, byte[] buffer, int bufferOffset, int length)
Parameters
Name Description
ordinal Int32
fieldOffset Int64
buffer Byte[]
bufferOffset Int32
length Int32
Returns
Type Description
Int64
Overrides

GetChar(Int32)

public override char GetChar(int i)
Parameter
Name Description
i Int32
Returns
Type Description
Char
Overrides

GetChars(Int32, Int64, Char[], Int32, Int32)

public override long GetChars(int i, long fieldoffset, char[] buffer, int bufferoffset, int length)
Parameters
Name Description
i Int32
fieldoffset Int64
buffer Char[]
bufferoffset Int32
length Int32
Returns
Type Description
Int64
Overrides

GetDataTypeName(Int32)

public override string GetDataTypeName(int i)
Parameter
Name Description
i Int32
Returns
Type Description
String
Overrides

GetDateTime(Int32)

public override DateTime GetDateTime(int i)
Parameter
Name Description
i Int32
Returns
Type Description
DateTime
Overrides

GetDecimal(Int32)

public override decimal GetDecimal(int i)
Parameter
Name Description
i Int32
Returns
Type Description
Decimal
Overrides

GetDouble(Int32)

public override double GetDouble(int i)
Parameter
Name Description
i Int32
Returns
Type Description
Double
Overrides

GetEnumerator()

public override IEnumerator GetEnumerator()
Returns
Type Description
IEnumerator
Overrides

GetFieldType(Int32)

public override Type GetFieldType(int i)
Parameter
Name Description
i Int32
Returns
Type Description
Type
Overrides

GetFieldValue<T>(Int32)

public override T GetFieldValue<T>(int ordinal)
Parameter
Name Description
ordinal Int32
Returns
Type Description
T
Type Parameter
Name Description
T
Overrides

GetFieldValue<T>(String)

public T GetFieldValue<T>(string columnName)

Gets the value of the specified column as type T.

Parameter
Name Description
columnName String

The name of the column whose value will be returned. Must not be null.

Returns
Type Description
T

The value of the column at the current row, converted to type T.

Type Parameter
Name Description
T

The expected return type. If possible the return type will be converted to this type. If conversion is requested between incompatible types, an InvalidOperationException will be thrown. If the conversion fails due to the contents returned (for example a string representing a boolean does not have either 'true' or 'false') then a FormatException exception will be thrown as documented by the Convert class.

GetFloat(Int32)

public override float GetFloat(int i)
Parameter
Name Description
i Int32
Returns
Type Description
Single
Overrides

GetGuid(Int32)

public override Guid GetGuid(int i)
Parameter
Name Description
i Int32
Returns
Type Description
Guid
Overrides

GetInt16(Int32)

public override short GetInt16(int i)
Parameter
Name Description
i Int32
Returns
Type Description
Int16
Overrides

GetInt32(Int32)

public override int GetInt32(int i)
Parameter
Name Description
i Int32
Returns
Type Description
Int32
Overrides

GetInt64(Int32)

public override long GetInt64(int i)
Parameter
Name Description
i Int32
Returns
Type Description
Int64
Overrides

GetJsonValue(Int32)

public Value GetJsonValue(int i)

Gets the value of the specified column as a pure Protobuf type.

Parameter
Name Description
i Int32

The index of the column whose value will be returned.

Returns
Type Description
Value

The raw protobuf as a Value.

Exceptions
Type Description
InvalidOperationException

The reader is not currently positioned on a valid row.

GetName(Int32)

public override string GetName(int i)
Parameter
Name Description
i Int32
Returns
Type Description
String
Overrides

GetNumeric(Int32)

public SpannerNumeric GetNumeric(int i)

Gets the value of the specified column as type SpannerNumeric.

Parameter
Name Description
i Int32

The index of the column to retrieve.

Returns
Type Description
SpannerNumeric

The value converted to a SpannerNumeric.

GetOrdinal(String)

public override int GetOrdinal(string name)
Parameter
Name Description
name String
Returns
Type Description
Int32
Overrides

GetOrdinalAsync(String, CancellationToken)

public async Task<int> GetOrdinalAsync(string name, CancellationToken cancellationToken = default(CancellationToken))

Returns the column ordinal given the name of the column, asynchronously requesting metadata from the database if necessary.

Parameters
Name Description
name String

The name of the column.

cancellationToken CancellationToken

A cancellation token to cancel reading metadata. Defaults to None.

Returns
Type Description
Task<Int32>

The zero-based column ordinal.

GetPgNumeric(Int32)

public PgNumeric GetPgNumeric(int i)

Gets the value of the specified column as type PgNumeric.

Parameter
Name Description
i Int32

The index of the column to retrieve.

Returns
Type Description
PgNumeric

The value converted to a PgNumeric.

GetReadTimestamp()

public Timestamp GetReadTimestamp()

Gets the read timestamp if ReturnReadTimestamp was true else returns null.

Returns
Type Description
Timestamp

The value converted to a Timestamp, or null if ReturnReadTimestamp was false.

Remarks

The read timestamp can be read before Read() or ReadAsync(CancellationToken) is called.

GetReadTimestampAsync(CancellationToken)

public Task<Timestamp> GetReadTimestampAsync(CancellationToken cancellationToken)

Gets the read timestamp if ReturnReadTimestamp was true else returns null.

Parameter
Name Description
cancellationToken CancellationToken
Returns
Type Description
Task<Timestamp>

The value converted to a Timestamp, or null if ReturnReadTimestamp was false.

GetSchemaTable()

public override DataTable GetSchemaTable()

When enabled, returns the schema of the query as a DataTable. This feature needs to be enabled in the connection string via the EnableGetSchemaTable property.

Returns
Type Description
DataTable

A DataTable with schema information about the query, or null if the feature is not enabled in the connection string.

Overrides Remarks

DbDataAdapter will use this method automatically, but there is not enough information available for it to do so to reliably manage data sets. This method returns null by default to avoid this causing problems.

When the EnableGetSchemaTable property in the connection string is set to true, a DataTable is returned with the following columns populated:

  • ColumnName (String): The name of the column
  • ColumnOrdinal (Int32): The ordinal value of the column
  • DataType (Type): The default CLR type of the column
  • ProviderType (SpannerDbType): The Spanner-specific data type of the column
The following additional columns are present in the table, but not currently populated:
  • ColumnSize
  • NumericPrecision
  • NumericScale
Future releases may expand the set of columns, or populate more of the existing columns.

GetSpannerDate(Int32)

public SpannerDate GetSpannerDate(int i)

Gets the value of the specified column as type SpannerDate.

Parameter
Name Description
i Int32

The index of the column to retrieve.

Returns
Type Description
SpannerDate

The value converted to a SpannerDate.

GetString(Int32)

public override string GetString(int i)
Parameter
Name Description
i Int32
Returns
Type Description
String
Overrides

GetTimestamp(Int32)

public Timestamp GetTimestamp(int i)

Gets the value of the specified column as type Timestamp.

Parameter
Name Description
i Int32

The index of the column to retrieve.

Returns
Type Description
Timestamp

The value converted to a Timestamp.

GetValue(Int32)

public override object GetValue(int i)
Parameter
Name Description
i Int32
Returns
Type Description
Object
Overrides

GetValues(Object[])

public override int GetValues(object[] values)
Parameter
Name Description
values Object[]
Returns
Type Description
Int32
Overrides

IsDBNull(Int32)

public override bool IsDBNull(int i)
Parameter
Name Description
i Int32
Returns
Type Description
Boolean
Overrides

NextResult()

public override bool NextResult()
Returns
Type Description
Boolean
Overrides

Read()

public override bool Read()
Returns
Type Description
Boolean
Overrides

ReadAsync(CancellationToken)

public override Task<bool> ReadAsync(CancellationToken cancellationToken)

Reads the next row of values from Cloud Spanner. Important: Cloud Spanner supports limited cancellation of this task.

Parameter
Name Description
cancellationToken CancellationToken

A cancellation token to cancel the read. Cloud Spanner currently supports limited cancellation while advancing the read to the next row.

Returns
Type Description
Task<Boolean>

True if another row was read.

Overrides