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 Query : IMessage<Query>, IEquatable<Query>, IDeepCloneable<Query>, IBufferMessage, IMessage

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

A query for entities.

The query stages are executed in the following order:

1. kind
2. filter
3. projection
4. order + start_cursor + end_cursor
5. offset
6. limit
7. find_nearest

## Inheritance

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

## Implements

[IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage-1.html)[Query](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.V1/latest/Google.Cloud.Datastore.V1.Query), [IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[Query](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.V1/latest/Google.Cloud.Datastore.V1.Query), [IDeepCloneable](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IDeepCloneable-1.html)[Query](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.V1/latest/Google.Cloud.Datastore.V1.Query), [IBufferMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IBufferMessage.html), [IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage.html)

## 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

### Query()

    public Query()

### Query(Query)

    public Query(Query other)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `other` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.V1/latest/Google.Cloud.Datastore.V1.Query` |

### Query(string)

    public Query(string kind)

Creates a query over the given kind.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `kind` | `https://learn.microsoft.com/dotnet/api/system.string` The kind of the query. Must not be null. |

## Properties

### DistinctOn

    public RepeatedField<PropertyReference> DistinctOn { get; }

The properties to make distinct. The query results will contain the first
result for each distinct combination of values for the given properties
(if empty, all results are returned).

Requires:

- If `order` is specified, the set of distinct on properties must appear before the non-distinct on properties in `order`.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Collections.RepeatedField-1.htmlhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.V1/latest/Google.Cloud.Datastore.V1.PropertyReference` |   |

### EndCursor

    public ByteString EndCursor { get; set; }

An ending point for the query results. Query cursors are
returned in query result batches and
[can only be used to limit the same
query](https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets).

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.ByteString.html` |   |

### Filter

    public Filter Filter { get; set; }

The filter to apply.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.V1/latest/Google.Cloud.Datastore.V1.Filter` |   |

### FindNearest

    public FindNearest FindNearest { get; set; }

Optional. A potential Nearest Neighbors Search.

Applies after all other filters and ordering.

Finds the closest vector embeddings to the given query vector.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.V1/latest/Google.Cloud.Datastore.V1.FindNearest` |   |

### Kind

    public RepeatedField<KindExpression> Kind { get; }

The kinds to query (if empty, returns entities of all kinds).
Currently at most 1 kind may be specified.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Collections.RepeatedField-1.htmlhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.V1/latest/Google.Cloud.Datastore.V1.KindExpression` |   |

### Limit

    public int? Limit { get; set; }

The maximum number of results to return. Applies after all other
constraints. Optional.
Unspecified is interpreted as no limit.
Must be \>= 0 if specified.

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

### Offset

    public int Offset { get; set; }

The number of results to skip. Applies before limit, but after all other
constraints. Optional. Must be \>= 0 if specified.

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

### Order

    public RepeatedField<PropertyOrder> Order { get; }

The order to apply to the query results (if empty, order is unspecified).

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Collections.RepeatedField-1.htmlhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.V1/latest/Google.Cloud.Datastore.V1.PropertyOrder` |   |

### Projection

    public RepeatedField<Projection> Projection { get; }

The projection to return. Defaults to returning all properties.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Collections.RepeatedField-1.htmlhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Datastore.V1/latest/Google.Cloud.Datastore.V1.Projection` |   |

### StartCursor

    public ByteString StartCursor { get; set; }

A starting point for the query results. Query cursors are
returned in query result batches and
[can only be used to continue the same
query](https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets).

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.ByteString.html` |   |