# Google Cloud Spanner v1 API - Class ReliableStreamReader (5.13.0-beta07)

5.13.0-beta07 5.13.0-beta06 5.12.0 (latest) 5.11.0 5.10.0 5.9.0 5.8.0 5.7.0 5.6.0 5.5.0 5.4.0 5.3.0 5.2.0 5.1.0 5.0.0 4.6.0 4.5.0 4.4.0 4.3.0 4.2.0 4.1.0 4.0.0 3.15.1 3.14.0 3.13.0 3.12.0 3.11.0 3.10.0 3.9.0 3.8.0 3.7.0 3.6.0 3.5.0

    public sealed class ReliableStreamReader : IDisposable

Reference documentation and code samples for the Google Cloud Spanner v1 API class ReliableStreamReader.

Provides streaming access to a Spanner SQL query that automatically retries, handles
chunking and recoverable errors.

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> ReliableStreamReader

## Implements

[IDisposable](https://learn.microsoft.com/dotnet/api/system.idisposable)

## Inherited Members

[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Namespace

[Google.Cloud.Spanner.V1](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1)

## Assembly

Google.Cloud.Spanner.V1.dll

## Properties

### IsClosed

    public bool IsClosed { get; }

Indicates whether the reader is closed or not.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.boolean` |   |

### Stats

    public ResultSetStats Stats { get; }

The statistics for the results, if present. These are only present on the last RPC
response from the server. They can be observed while that final response is being consumed, or afterwards.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.ResultSetStats` |   |

## Methods

### Close()

    public void Close()

Closes the stream reader.

### Dispose()

    public void Dispose()

### EnsureInitializedAsync(CancellationToken)

    public Task EnsureInitializedAsync(CancellationToken cancellationToken)

Ensures the stream reader is initialized, i.e. that the request has been executed and we've received
appropriate metadata.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` A cancellation token for the asynchronous operation. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task` | A task indicating the result of initialization. |

### \~ReliableStreamReader()

    protected ~ReliableStreamReader()

### GetMetadataAsync(CancellationToken)

    public Task<ResultSetMetadata> GetMetadataAsync(CancellationToken cancellationToken)

Asynchronously retrieves the metadata associated with this stream.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` A cancellation token for the asynchronous operation. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.ResultSetMetadata` | A task which, when completed, will contain the metadata for the stream. |

### HasDataAsync(CancellationToken)

    public Task<bool> HasDataAsync(CancellationToken cancellationToken)

Determines whether this stream has any more data or not.
This is equivalent to calling [NextAsync(CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.ReliableStreamReader#Google_Cloud_Spanner_V1_ReliableStreamReader_NextAsync_System_Threading_CancellationToken_) to see whether the return
value is null, but without consuming the value from the stream.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` A cancellation token for the asynchronous operation. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://learn.microsoft.com/dotnet/api/system.boolean` | A task which, when completed, will indicate whether the stream contains data. |

### NextAsync(CancellationToken)

    public Task<Value> NextAsync(CancellationToken cancellationToken)

Asynchronously reads the next value from the stream. A null value indicates the end of the stream.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` A cancellation token for the asynchronous operation. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.WellKnownTypes.Value.html` | A task which, when completed, will provide the next value read from the stream. |

## Events

### StreamClosed

    public event EventHandler<StreamClosedEventArgs> StreamClosed

Event invoked when the stream is closed.

| **Event Type** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.eventhandler-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.StreamClosedEventArgs` |   |