# Class GrpcPagedAsyncEnumerable&lt;TRequest, TResponse, TResource&gt; (4.10.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [4.10.0 (latest)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.GrpcPagedAsyncEnumerable-3)
- [4.8.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/4.8.0/Google.Api.Gax.Grpc.GrpcPagedAsyncEnumerable-3)
- [4.4.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/4.4.0/Google.Api.Gax.Grpc.GrpcPagedAsyncEnumerable-3)
- [4.3.1](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/4.3.1/Google.Api.Gax.Grpc.GrpcPagedAsyncEnumerable-3)
- [4.2.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/4.2.0/Google.Api.Gax.Grpc.GrpcPagedAsyncEnumerable-3)
- [4.0.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/4.0.0/Google.Api.Gax.Grpc.GrpcPagedAsyncEnumerable-3)
- [3.2.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/3.2.0/Google.Api.Gax.Grpc.GrpcPagedAsyncEnumerable-3)

    public sealed class GrpcPagedAsyncEnumerable<TRequest, TResponse, TResource> : PagedAsyncEnumerable<TResponse, TResource>, IAsyncEnumerable<TResource> where TRequest : class, IPageRequest, IMessage<TRequest> where TResponse : class, IPageResponse<TResource>, IMessage<TResponse>

An asynchronous sequence of resources, obtained lazily via API operations which retrieve a page at a time.

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> [PagedAsyncEnumerable](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.PagedAsyncEnumerable-2) \> GrpcPagedAsyncEnumerable\<TRequest, TResponse, TResource\>

## Implements

[IAsyncEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.iasyncenumerable-1)

## Inherited Members

[PagedAsyncEnumerable\<TResponse, TResource\>.AsRawResponses()](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.PagedAsyncEnumerable-2#Google_Api_Gax_PagedAsyncEnumerable_2_AsRawResponses) [PagedAsyncEnumerable\<TResponse, TResource\>.ReadPageAsync(int, CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.PagedAsyncEnumerable-2#Google_Api_Gax_PagedAsyncEnumerable_2_ReadPageAsync_System_Int32_System_Threading_CancellationToken_) [PagedAsyncEnumerable\<TResponse, TResource\>.GetAsyncEnumerator(CancellationToken)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.PagedAsyncEnumerable-2#Google_Api_Gax_PagedAsyncEnumerable_2_GetAsyncEnumerator_System_Threading_CancellationToken_) [object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)) [object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)) [object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) [object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals) [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Namespace

[Google.Api.Gax.Grpc](https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc)

## Assembly

Google.Api.Gax.Grpc.dll

| ## Type Parameters ||
|---|---|
| **Name** | **Description** |
| `TRequest` | The API request type. |
| `TResponse` | The API response type. Each response contains a page of resources. |
| `TResource` | The resource type contained within the response. |

## Constructors

### GrpcPagedAsyncEnumerable(ApiCall\<TRequest, TResponse\>, TRequest, CallSettings)

    public GrpcPagedAsyncEnumerable(ApiCall<TRequest, TResponse> apiCall, TRequest request, CallSettings callSettings)

Creates a new lazily-evaluated asynchronous sequence from the given API call, initial request, and call settings.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `apiCall` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.ApiCall-2` The API call made each time a page is required. |
| `request` | `TRequest` The initial request. |
| `callSettings` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Grpc.CallSettings` The settings to apply to each API call. |

**Remarks** The request is cloned each time the sequence is evaluated.

## Methods

### AsRawResponses()

    public override IAsyncEnumerable<TResponse> AsRawResponses()

Returns the sequence of raw API responses, each of which contributes a page of
resources to this sequence.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.collections.generic.iasyncenumerable-1` | An asynchronous sequence of raw API responses, each containing a page of resources. |

**Overrides** Google.Api.Gax.PagedAsyncEnumerable\<TResponse, TResource\>.AsRawResponses()

### GetAsyncEnumerator(CancellationToken)

    public override IAsyncEnumerator<TResource> GetAsyncEnumerator(CancellationToken cancellationToken = default)

Returns an enumerator that iterates asynchronously through the collection.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` A [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken) that may be used to cancel the asynchronous iteration. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.collections.generic.iasyncenumerator-1` | An enumerator that can be used to iterate asynchronously through the collection. |

**Overrides** [PagedAsyncEnumerable\<TResponse, TResource\>.GetAsyncEnumerator(CancellationToken)](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken)

### ReadPageAsync(int, CancellationToken)

    public override Task<Page<TResource>> ReadPageAsync(int pageSize, CancellationToken cancellationToken = default)

Eagerly (but asynchronously) reads a single page of results with a fixed maximum size. The returned page is guaranteed
to have that many results, unless there is no more data available.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `pageSize` | `https://learn.microsoft.com/dotnet/api/system.int32` The page size. Must be greater than 0. |
| `cancellationToken` | `https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken` A token to cancel the operation. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.threading.tasks.task-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.Page-1` | An asynchronous operation, the result of which is a page of resources. |

**Overrides** [PagedAsyncEnumerable\<TResponse, TResource\>.ReadPageAsync(int, CancellationToken)](https://learn.microsoft.com/dotnet/api/system.int32) **Remarks** "Natural" pages returned by the API may contain a smaller number of resources than requested.
For example, a request for a page with 100 resources may return a page with 80 resources but
a next page token for more to be retrieved. This is suitable for batch-processing, but not
for user-visible paging such as in a web application, where fixed-size pages are expected.
This method may make more than one API call in order to fill the page, but after the page has been
returned, all the data will have been loaded. (In particular, iterating over the items in the page
multiple times will not make any further requests.)