public sealed class SpannerDataReader : DbDataReader, IEnumerable, IDataReader, IDataRecord, IDisposable
Reads a forward-only stream of rows from a data source.
Namespace
Google.Cloud.Spanner.DataAssembly
Google.Cloud.Spanner.Data.dll
Properties
Depth
public override int Depth { get; }
Property Value | |
---|---|
Type | Description |
Int32 |
FieldCount
public override int FieldCount { get; }
Property Value | |
---|---|
Type | Description |
Int32 |
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 |
IsClosed
public override bool IsClosed { get; }
Property Value | |
---|---|
Type | Description |
Boolean |
Item[Int32]
public override object this[int i] { get; }
Parameter | |
---|---|
Name | Description |
i |
Int32 |
Property Value | |
---|---|
Type | Description |
Object |
Item[String]
public override object this[string name] { get; }
Parameter | |
---|---|
Name | Description |
name |
String |
Property Value | |
---|---|
Type | Description |
Object |
RecordsAffected
public override int RecordsAffected { get; }
Property Value | |
---|---|
Type | Description |
Int32 |
Methods
Close()
public override void Close()
Dispose(Boolean)
protected override void Dispose(bool disposing)
Parameter | |
---|---|
Name | Description |
disposing |
Boolean |
GetBoolean(Int32)
public override bool GetBoolean(int i)
Parameter | |
---|---|
Name | Description |
i |
Int32 |
Returns | |
---|---|
Type | Description |
Boolean |
GetByte(Int32)
public override byte GetByte(int i)
Parameter | |
---|---|
Name | Description |
i |
Int32 |
Returns | |
---|---|
Type | Description |
Byte |
GetBytes(Int32, Int64, Byte[], Int32, Int32)
public override long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferoffset, int length)
Parameters | |
---|---|
Name | Description |
i |
Int32 |
fieldOffset |
Int64 |
buffer |
Byte[] |
bufferoffset |
Int32 |
length |
Int32 |
Returns | |
---|---|
Type | Description |
Int64 |
GetChar(Int32)
public override char GetChar(int i)
Parameter | |
---|---|
Name | Description |
i |
Int32 |
Returns | |
---|---|
Type | Description |
Char |
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 |
GetDataTypeName(Int32)
public override string GetDataTypeName(int i)
Parameter | |
---|---|
Name | Description |
i |
Int32 |
Returns | |
---|---|
Type | Description |
String |
GetDateTime(Int32)
public override DateTime GetDateTime(int i)
Parameter | |
---|---|
Name | Description |
i |
Int32 |
Returns | |
---|---|
Type | Description |
DateTime |
GetDecimal(Int32)
public override decimal GetDecimal(int i)
Parameter | |
---|---|
Name | Description |
i |
Int32 |
Returns | |
---|---|
Type | Description |
Decimal |
GetDouble(Int32)
public override double GetDouble(int i)
Parameter | |
---|---|
Name | Description |
i |
Int32 |
Returns | |
---|---|
Type | Description |
Double |
GetEnumerator()
public override IEnumerator GetEnumerator()
Returns | |
---|---|
Type | Description |
IEnumerator |
GetFieldType(Int32)
public override Type GetFieldType(int i)
Parameter | |
---|---|
Name | Description |
i |
Int32 |
Returns | |
---|---|
Type | Description |
Type |
GetFieldValue<T>(Int32)
public override T GetFieldValue<T>(int ordinal)
Parameter | |
---|---|
Name | Description |
ordinal |
Int32 |
Returns | |
---|---|
Type | Description |
T |
Type Parameter | |
---|---|
Name | Description |
T |
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 |
GetGuid(Int32)
public override Guid GetGuid(int i)
Parameter | |
---|---|
Name | Description |
i |
Int32 |
Returns | |
---|---|
Type | Description |
Guid |
GetInt16(Int32)
public override short GetInt16(int i)
Parameter | |
---|---|
Name | Description |
i |
Int32 |
Returns | |
---|---|
Type | Description |
Int16 |
GetInt32(Int32)
public override int GetInt32(int i)
Parameter | |
---|---|
Name | Description |
i |
Int32 |
Returns | |
---|---|
Type | Description |
Int32 |
GetInt64(Int32)
public override long GetInt64(int i)
Parameter | |
---|---|
Name | Description |
i |
Int32 |
Returns | |
---|---|
Type | Description |
Int64 |
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 |
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 |
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 | |
---|---|
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. |
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 |
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 |
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 |
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
- ColumnSize
- NumericPrecision
- NumericScale
GetString(Int32)
public override string GetString(int i)
Parameter | |
---|---|
Name | Description |
i |
Int32 |
Returns | |
---|---|
Type | Description |
String |
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 |
GetValues(Object[])
public override int GetValues(object[] values)
Parameter | |
---|---|
Name | Description |
values |
Object[] |
Returns | |
---|---|
Type | Description |
Int32 |
IsDBNull(Int32)
public override bool IsDBNull(int i)
Parameter | |
---|---|
Name | Description |
i |
Int32 |
Returns | |
---|---|
Type | Description |
Boolean |
NextResult()
public override bool NextResult()
Returns | |
---|---|
Type | Description |
Boolean |
Read()
public override bool Read()
Returns | |
---|---|
Type | Description |
Boolean |
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. |