Class SpannerDataReader (3.7.0)

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

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
TypeDescription
Int32
Overrides

FieldCount

public override int FieldCount { get; }
Property Value
TypeDescription
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
TypeDescription
Boolean
Overrides

IsClosed

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

Item[Int32]

public override object this[int i] { get; }
Parameter
NameDescription
iInt32
Property Value
TypeDescription
Object
Overrides

Item[String]

public override object this[string name] { get; }
Parameter
NameDescription
nameString
Property Value
TypeDescription
Object
Overrides

RecordsAffected

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

Methods

Close()

public override void Close()
Overrides

Dispose(Boolean)

protected override void Dispose(bool disposing)
Parameter
NameDescription
disposingBoolean
Overrides

GetBoolean(Int32)

public override bool GetBoolean(int i)
Parameter
NameDescription
iInt32
Returns
TypeDescription
Boolean
Overrides

GetByte(Int32)

public override byte GetByte(int i)
Parameter
NameDescription
iInt32
Returns
TypeDescription
Byte
Overrides

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

public override long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferoffset, int length)
Parameters
NameDescription
iInt32
fieldOffsetInt64
bufferByte[]
bufferoffsetInt32
lengthInt32
Returns
TypeDescription
Int64
Overrides

GetChar(Int32)

public override char GetChar(int i)
Parameter
NameDescription
iInt32
Returns
TypeDescription
Char
Overrides

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

public override long GetChars(int i, long fieldoffset, char[] buffer, int bufferoffset, int length)
Parameters
NameDescription
iInt32
fieldoffsetInt64
bufferChar[]
bufferoffsetInt32
lengthInt32
Returns
TypeDescription
Int64
Overrides

GetDataTypeName(Int32)

public override string GetDataTypeName(int i)
Parameter
NameDescription
iInt32
Returns
TypeDescription
String
Overrides

GetDateTime(Int32)

public override DateTime GetDateTime(int i)
Parameter
NameDescription
iInt32
Returns
TypeDescription
DateTime
Overrides

GetDecimal(Int32)

public override decimal GetDecimal(int i)
Parameter
NameDescription
iInt32
Returns
TypeDescription
Decimal
Overrides

GetDouble(Int32)

public override double GetDouble(int i)
Parameter
NameDescription
iInt32
Returns
TypeDescription
Double
Overrides

GetEnumerator()

public override IEnumerator GetEnumerator()
Returns
TypeDescription
IEnumerator
Overrides

GetFieldType(Int32)

public override Type GetFieldType(int i)
Parameter
NameDescription
iInt32
Returns
TypeDescription
Type
Overrides

GetFieldValue<T>(Int32)

public override T GetFieldValue<T>(int ordinal)
Parameter
NameDescription
ordinalInt32
Returns
TypeDescription
T
Type Parameter
NameDescription
T
Overrides

GetFieldValue<T>(String)

public T GetFieldValue<T>(string columnName)

Gets the value of the specified column as type T.

Parameter
NameDescription
columnNameString

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

Returns
TypeDescription
T

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

Type Parameter
NameDescription
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
NameDescription
iInt32
Returns
TypeDescription
Single
Overrides

GetGuid(Int32)

public override Guid GetGuid(int i)
Parameter
NameDescription
iInt32
Returns
TypeDescription
Guid
Overrides

GetInt16(Int32)

public override short GetInt16(int i)
Parameter
NameDescription
iInt32
Returns
TypeDescription
Int16
Overrides

GetInt32(Int32)

public override int GetInt32(int i)
Parameter
NameDescription
iInt32
Returns
TypeDescription
Int32
Overrides

GetInt64(Int32)

public override long GetInt64(int i)
Parameter
NameDescription
iInt32
Returns
TypeDescription
Int64
Overrides

GetJsonValue(Int32)

public Value GetJsonValue(int i)

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

Parameter
NameDescription
iInt32

The index of the column whose value will be returned.

Returns
TypeDescription
Value

The raw protobuf as a Value.

Exceptions
TypeDescription
InvalidOperationException

The reader is not currently positioned on a valid row.

GetName(Int32)

public override string GetName(int i)
Parameter
NameDescription
iInt32
Returns
TypeDescription
String
Overrides

GetNumeric(Int32)

public SpannerNumeric GetNumeric(int i)

Gets the value of the specified column as type Google.Cloud.Spanner.V1.SpannerNumeric.

Parameter
NameDescription
iInt32

The index of the column to retrieve.

Returns
TypeDescription
Google.Cloud.Spanner.V1.SpannerNumeric

The value converted to a Google.Cloud.Spanner.V1.SpannerNumeric.

GetOrdinal(String)

public override int GetOrdinal(string name)
Parameter
NameDescription
nameString
Returns
TypeDescription
Int32
Overrides

GetOrdinalAsync(String, CancellationToken)

public 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
NameDescription
nameString

The name of the column.

cancellationTokenCancellationToken

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

Returns
TypeDescription
Task<Int32>

The zero-based column ordinal.

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
TypeDescription
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.

GetString(Int32)

public override string GetString(int i)
Parameter
NameDescription
iInt32
Returns
TypeDescription
String
Overrides

GetTimestamp(Int32)

public Timestamp GetTimestamp(int i)

Gets the value of the specified column as type Timestamp.

Parameter
NameDescription
iInt32

The index of the column to retrieve.

Returns
TypeDescription
Timestamp

The value converted to a Timestamp.

GetValue(Int32)

public override object GetValue(int i)
Parameter
NameDescription
iInt32
Returns
TypeDescription
Object
Overrides

GetValues(Object[])

public override int GetValues(object[] values)
Parameter
NameDescription
valuesObject[]
Returns
TypeDescription
Int32
Overrides

IsDBNull(Int32)

public override bool IsDBNull(int i)
Parameter
NameDescription
iInt32
Returns
TypeDescription
Boolean
Overrides

NextResult()

public override bool NextResult()
Returns
TypeDescription
Boolean
Overrides

Read()

public override bool Read()
Returns
TypeDescription
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
NameDescription
cancellationTokenCancellationToken

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

Returns
TypeDescription
Task<Boolean>

True if another row was read.

Overrides