# GetEntityQuery

> Gets the cached query for the specified component types, if one exists; otherwise, creates a new query instance and caches it.

## Definition

* **Type:** Method
* **Namespace:** [Unity.Entities](/engine/7000.0/script-reference/unity/entities.md)
* **Assembly:** UnityEngine.EntitiesModule

## GetEntityQuery(ComponentType\[])

Gets the cached query for the specified component types, if one exists; otherwise, creates a new query instance and caches it.

```csharp
protected EntityQuery GetEntityQuery(params ComponentType[] componentTypes)
```

### Parameters

**** (\[ComponentType\[]]\(/engine/7000.0/script-reference/unity/entities/componenttype)): An array or comma-separated list of component types.

### Returns

| Type                                                                         | Description              |
| ---------------------------------------------------------------------------- | ------------------------ |
| [EntityQuery](/engine/7000.0/script-reference/unity/entities/entityquery.md) | The new or cached query. |

## GetEntityQuery(NativeArray\<ComponentType>)

Gets the cached query for the specified component types, if one exists; otherwise, creates a new query instance and caches it.

```csharp
protected EntityQuery GetEntityQuery(NativeArray<ComponentType> componentTypes)
```

### Parameters

**** (\[NativeArray\<ComponentType>]\(/engine/7000.0/script-reference/unity/collections/nativearray1)): An array of component types.

### Returns

| Type                                                                         | Description              |
| ---------------------------------------------------------------------------- | ------------------------ |
| [EntityQuery](/engine/7000.0/script-reference/unity/entities/entityquery.md) | The new or cached query. |

## GetEntityQuery(EntityQueryDesc\[])

Combines an array of query description objects into a single query.

```csharp
protected EntityQuery GetEntityQuery(params EntityQueryDesc[] queryDesc)
```

### Parameters

**** (\[EntityQueryDesc\[]]\(/engine/7000.0/script-reference/unity/entities/entityquerydesc)): An array of query description objects to be combined to define the query.

### Returns

| Type                                                                         | Description              |
| ---------------------------------------------------------------------------- | ------------------------ |
| [EntityQuery](/engine/7000.0/script-reference/unity/entities/entityquery.md) | The new or cached query. |

### Remarks

This function looks for a cached query matching the combined query descriptions, and returns it if one exists; otherwise, the function creates a new query instance and caches it.

## GetEntityQuery(EntityQueryBuilder)

Create an entity query from a query description builder.

```csharp
public EntityQuery GetEntityQuery(in EntityQueryBuilder builder)
```

### Parameters

**** (\[EntityQueryBuilder]\(/engine/7000.0/script-reference/unity/entities/entityquerybuilder)): The description builder

### Returns

| Type                                                                         | Description              |
| ---------------------------------------------------------------------------- | ------------------------ |
| [EntityQuery](/engine/7000.0/script-reference/unity/entities/entityquery.md) | The new or cached query. |

### Remarks

This function looks for a cached query matching the combined query descriptions, and returns it if one exists; otherwise, the function creates a new query instance and caches it.
