# Google BigQuery v2 API - Class BigQueryResults (3.12.0)

3.12.0 (latest) 3.11.0 3.10.0 3.9.0 3.8.0 3.7.0 3.6.0 3.5.0 3.4.0 3.3.0 3.2.0 3.1.0 3.0.0 2.4.0 2.3.0 2.2.0

    public sealed class BigQueryResults : IEnumerable<BigQueryRow>, IEnumerable

Reference documentation and code samples for the Google BigQuery v2 API class BigQueryResults.

The results of a completed query.

## Inheritance

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

## Implements

[IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)[BigQueryRow](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.BigQuery.V2/latest/Google.Cloud.BigQuery.V2.BigQueryRow), [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.ienumerable)

## 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.BigQuery.V2](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.BigQuery.V2/latest/Google.Cloud.BigQuery.V2)

## Assembly

Google.Cloud.BigQuery.V2.dll

## Constructors

### BigQueryResults(BigQueryClient, GetQueryResultsResponse, TableReference, GetQueryResultsOptions)

    public BigQueryResults(BigQueryClient client, GetQueryResultsResponse response, TableReference tableReference, GetQueryResultsOptions options)

Constructs a new set of results.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `client` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.BigQuery.V2/latest/Google.Cloud.BigQuery.V2.BigQueryClient` The client to use for further operations. Must not be null. |
| `response` | `https://googleapis.dev/dotnet/Google.Apis.Bigquery.v2/1.74.0.4090/api/Google.Apis.Bigquery.v2.Data.GetQueryResultsResponse.html` The response to a GetQueryResults API call. Must not be null. |
| `tableReference` | `https://googleapis.dev/dotnet/Google.Apis.Bigquery.v2/1.74.0.4090/api/Google.Apis.Bigquery.v2.Data.TableReference.html` A reference to the table containing the results. May be null. (For example, script queries don't store results in tables.) |
| `options` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.BigQuery.V2/latest/Google.Cloud.BigQuery.V2.GetQueryResultsOptions` Options to use when fetching results. May be null. |

**Remarks** This is public to allow tests to construct instances for production code to consume;
production code should not normally construct instances itself.

## Properties

### CacheHit

    public bool CacheHit { get; }

Whether the query result was fetched from the query cache.

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

### JobReference

    public JobReference JobReference { get; }

The reference to the query job.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://googleapis.dev/dotnet/Google.Apis.Bigquery.v2/1.74.0.4090/api/Google.Apis.Bigquery.v2.Data.JobReference.html` |   |

### NumDmlAffectedRows

    public long? NumDmlAffectedRows { get; }

The total number of rows affected by a DML statement, or `null` for non-DML results.

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

### QueryId

    public string QueryId { get; }

The query ID if executed as a stateless query or `null` otherwise.

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

### Schema

    public TableSchema Schema { get; }

The schema of the query.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://googleapis.dev/dotnet/Google.Apis.Bigquery.v2/1.74.0.4090/api/Google.Apis.Bigquery.v2.Data.TableSchema.html` |   |

### TableReference

    public TableReference TableReference { get; }

The reference to the table containing the query results.
May be null. (For example, script queries don't store results in tables.)

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://googleapis.dev/dotnet/Google.Apis.Bigquery.v2/1.74.0.4090/api/Google.Apis.Bigquery.v2.Data.TableReference.html` |   |

### TotalRows

    public ulong? TotalRows { get; }

The total number of rows in the results, or `null` if the query results do not provide a row count.

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

## Methods

### GetEnumerator()

    public IEnumerator<BigQueryRow> GetEnumerator()

Returns an iterator over the query results.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerator-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.BigQuery.V2/latest/Google.Cloud.BigQuery.V2.BigQueryRow` | An iterator over the query results. |

### GetRowsAsync()

    public IAsyncEnumerable<BigQueryRow> GetRowsAsync()

Returns an asynchronous sequence of rows from this set of results.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.collections.generic.iasyncenumerable-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.BigQuery.V2/latest/Google.Cloud.BigQuery.V2.BigQueryRow` | An asynchronous sequence of rows from this set of results. |

**Remarks** This method exists rather than making the class implement [IAsyncEnumerable\<T\>](https://learn.microsoft.com/dotnet/api/system.collections.generic.iasyncenumerable-1) to avoid
ambiguity.

### ReadPage(int)

    public BigQueryPage ReadPage(int pageSize)

Eagerly fetches a set of rows, up to the specified count, providing a page of results with a next page token
if more results are available. This is typically used within web applications, where the next page token
is propagated to the client along with the results, so that the next page can be retrieved in another request.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `pageSize` | `https://learn.microsoft.com/dotnet/api/system.int32` The maximum number of rows to retrieve. Must be positive. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.BigQuery.V2/latest/Google.Cloud.BigQuery.V2.BigQueryPage` | An in-memory result set of at most the given number of rows. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.invalidoperationexception` | Thrown when attempting to run this method on results that did not create a job. Use the default [Required](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.BigQuery.V2/latest/Google.Cloud.BigQuery.V2.JobCreationMode#Google_Cloud_BigQuery_V2_JobCreationMode_Required) to ensure the job is created before calling this method. |

### ReadPageAsync(int, CancellationToken)

    public Task<BigQueryPage> ReadPageAsync(int pageSize, CancellationToken cancellationToken = default)

Asynchronously but eagerly fetches a set of rows, up to the specified count, providing a page of results with a next page token
if more results are available. This is typically used within web applications, where the next page token
is propagated to the client along with the results, so that the next page can be retrieved in another request.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `pageSize` | `https://learn.microsoft.com/dotnet/api/system.int32` The maximum number of rows to retrieve. Must be positive. |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` The token to monitor for cancellation requests. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.BigQuery.V2/latest/Google.Cloud.BigQuery.V2.BigQueryPage` | A task representing the asynchronous operation. When complete, the result is an in-memory result set of at most the given number of rows. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.invalidoperationexception` | Thrown when attempting to run this method on results that did not create a job. Use the default [Required](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.BigQuery.V2/latest/Google.Cloud.BigQuery.V2.JobCreationMode#Google_Cloud_BigQuery_V2_JobCreationMode_Required) to ensure the job is created before calling this method. |

### ThrowOnAnyError()

    public BigQueryResults ThrowOnAnyError()

Returns `this` if the job has no errors, or throws an exception containing the
errors. A job may have errors but still contain useful information.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.BigQuery.V2/latest/Google.Cloud.BigQuery.V2.BigQueryResults` | `this` if the job has no errors. |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.GoogleApiException.html` | The job has errors. |