Class LazyDatastoreQuery (3.4.0)

public sealed class LazyDatastoreQuery : IEnumerable<Entity>, IEnumerable

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, Nullable<ReadOptions.Types.ReadConsistency>, CallSettings).

Parameter
NameDescription
responsesIEnumerable<RunQueryResponse>

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
TypeDescription
IEnumerable<RunQueryResponse>

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
TypeDescription
DatastoreQueryResults

The complete set of query results.

GetEnumerator()

public IEnumerator<Entity> GetEnumerator()
Returns
TypeDescription
IEnumerator<Entity>

Explicit Interface Implementations

IEnumerable.GetEnumerator()

IEnumerator IEnumerable.GetEnumerator()
Returns
TypeDescription
IEnumerator