5.3.0 (latest) 5.2.0 5.1.0 5.0.0 4.17.0 4.16.0 4.15.0 4.14.0 4.13.0 4.12.0 4.11.0 4.10.0 4.9.0 4.8.0 4.7.0 4.6.0 4.5.0 4.4.0 4.3.0 4.2.0 4.1.0 4.0.0 3.5.0 3.4.0 3.3.0 3.2.0

    public sealed class LazyDatastoreQuery : IEnumerable<Entity>, IEnumerable

Reference documentation and code samples for the Google Cloud Datastore v1 API class LazyDatastoreQuery.

A Datastore query which is executed lazily. Iterating over this object will provide a sequence
of entities; alternatively, all the results can be fetched using [GetAllResults()](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.V1/latest/Google.Cloud.Datastore.V1.LazyDatastoreQuery#Google_Cloud_Datastore_V1_LazyDatastoreQuery_GetAllResults),
or for diagnostic use cases the RPC responses can be viewed using [AsResponses()](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.V1/latest/Google.Cloud.Datastore.V1.LazyDatastoreQuery#Google_Cloud_Datastore_V1_LazyDatastoreQuery_AsResponses).
The lazy evaluation is important: if you iterate over the query multiple times, it will execute
multiple times, potentially returning different results each time.

## Inheritance

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

## Implements

[IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)[Entity](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.V1/latest/Google.Cloud.Datastore.V1.Entity), [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.Datastore.V1](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.V1/latest/Google.Cloud.Datastore.V1)

## Assembly

Google.Cloud.Datastore.V1.dll

## Constructors

### LazyDatastoreQuery(IEnumerable\<RunQueryResponse\>)

    public LazyDatastoreQuery(IEnumerable<RunQueryResponse> responses)

Constructs a new instance from the given sequence of responses. This constructor
is only present to facilitate testing; application code will normally obtain instances
of this class by calling [RunQueryLazily(Query, ReadConsistency?, CallSettings)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.V1/latest/Google.Cloud.Datastore.V1.DatastoreDb#Google_Cloud_Datastore_V1_DatastoreDb_RunQueryLazily_Google_Cloud_Datastore_V1_Query_System_Nullable_Google_Cloud_Datastore_V1_ReadOptions_Types_ReadConsistency__Google_Api_Gax_Grpc_CallSettings_).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `responses` | `https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.V1/latest/Google.Cloud.Datastore.V1.RunQueryResponse` The responses to return. |

**Remarks** The sequence of responses will be returned directly from [AsResponses()](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.V1/latest/Google.Cloud.Datastore.V1.LazyDatastoreQuery#Google_Cloud_Datastore_V1_LazyDatastoreQuery_AsResponses), and
used to lazily construct the other sequences returned by this class. It should not
contain any null references.

## Methods

### AsResponses()

    public IEnumerable<RunQueryResponse> AsResponses()

This method is for advanced use cases only, where more diagnostic information is required;
most application code should merely iterate over the query results as [Entity](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.V1/latest/Google.Cloud.Datastore.V1.Entity)
values, or call [GetAllResults()](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.V1/latest/Google.Cloud.Datastore.V1.LazyDatastoreQuery#Google_Cloud_Datastore_V1_LazyDatastoreQuery_GetAllResults).
The results of this query are returned as a sequence of [RunQueryResponse](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.V1/latest/Google.Cloud.Datastore.V1.RunQueryResponse) values
exactly as returned by the Datastore API.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.V1/latest/Google.Cloud.Datastore.V1.RunQueryResponse` | A sequence of [RunQueryResponse](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.V1/latest/Google.Cloud.Datastore.V1.RunQueryResponse) values. |

### GetAllResults()

    public DatastoreQueryResults GetAllResults()

Reads all the results from this query, until either the query-specified limit or end cursor
is reached, or there is no more data to read. Note that all the entities are read into memory,
so this method is not appropriate for use cases where a query could return a very large number
of results. However, it is the simplest approach to use cases where the query is bounded, such
as displaying a page of results at a time in a web application.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.V1/latest/Google.Cloud.Datastore.V1.DatastoreQueryResults` | The complete set of query results. |

### GetEnumerator()

    public IEnumerator<Entity> GetEnumerator()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerator-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.V1/latest/Google.Cloud.Datastore.V1.Entity` |   |