Google Cloud Datastore v1 API - Class LazyDatastoreQuery (4.10.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(), or for diagnostic use cases the RPC responses can be viewed using 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 > LazyDatastoreQuery

Namespace

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).

Parameter
Name Description
responses IEnumerableRunQueryResponse

The responses to return.

Remarks

The sequence of responses will be returned directly from 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 values, or call GetAllResults(). The results of this query are returned as a sequence of RunQueryResponse values exactly as returned by the Datastore API.

Returns
Type Description
IEnumerableRunQueryResponse

A sequence of 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
DatastoreQueryResults

The complete set of query results.

GetEnumerator()

public IEnumerator<Entity> GetEnumerator()
Returns
Type Description
IEnumeratorEntity