---
title: "Interface IQueryingClient"
slug: "sdk--stylelabs.m.sdk.clients.iqueryingclient"
abstract: ""
---
# Interface IQueryingClient

Contains functionality to query and scroll for entities.

## Namespace: StylelabsStylelabs.MSdkClients

## Assembly: Stylelabs.M.Sdk.dll

## Syntax

```csharp
public interface IQueryingClient
```

## Methods

### CreateEntityIdIterator(Query)

Creates an [IEntityIterator](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.querying.ientityiterator.html) that iterates over all ids matched by the [Query](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.base.querying.query.html).

#### Declaration

```csharp
IIdIterator CreateEntityIdIterator(Query query)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| [Query](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.base.querying.query.html) | query | The query to iterate. |

#### Returns

| Type | Description |
| --- | --- |
| [IIdIterator](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.querying.iiditerator.html) | An iterator. |

### CreateEntityIdScroller(Query, TimeSpan?)

Creates an [IIdScroller](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.querying.iidscroller.html) that scrolls over all ids of entities that match the [Query](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.base.querying.query.html).

#### Declaration

```csharp
IIdScroller CreateEntityIdScroller(Query query, TimeSpan? scrollTime = null)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| [Query](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.base.querying.query.html) | query | The query to scroll. |
| TimeSpan | scrollTime | The time for the scroll to live. If it is not specified, [ScrollTime](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.defaults.scrolling.html) will be used. The scroll time should not be too long, just enough to process each batch of results. |

#### Returns

| Type | Description |
| --- | --- |
| [IIdScroller](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.querying.iidscroller.html) | An [IIdScroller](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.querying.iidscroller.html) instance. |

#### Remarks

Use scrolling wisely and try to limit the `scrollTime` for the scroll to live. Using scrolling inappropriately can cause performance issues. See [https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html) for more information.

### CreateEntityIterator(Query, IEntityLoadConfiguration)

Creates an [IEntityIterator](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.querying.ientityiterator.html) that iterates over all results matched by the [Query](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.base.querying.query.html).

#### Declaration

```csharp
IEntityIterator CreateEntityIterator(Query query, IEntityLoadConfiguration loadConfiguration = null)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| [Query](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.base.querying.query.html) | query | The query to iterate. |
| [IEntityLoadConfiguration](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.framework.essentials.loadconfigurations.ientityloadconfiguration.html) | loadConfiguration | The load configuration. If it is null, then [Default](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.framework.essentials.loadconfigurations.entityloadconfiguration.html) will be used. |

#### Returns

| Type | Description |
| --- | --- |
| [IEntityIterator](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.querying.ientityiterator.html) | An iterator. |

#### Remarks

For compatibility with the 3.0 SDK, the loading configuration is resolved as follows:

1. The `loadConfiguration` will be used, if not null.
2. The [IQueryLoadConfiguration](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.framework.essentials.loadconfigurations.iqueryloadconfiguration.html) from the `query` will be used, if not null and if applicable.
3. Otherwise, defaults to [Default](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.framework.essentials.loadconfigurations.entityloadconfiguration.html).

### CreateEntityScroller(Query, TimeSpan?, IEntityLoadConfiguration)

Creates an [IEntityScroller](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.querying.ientityscroller.html) that scrolls over all entities that match the [Query](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.base.querying.query.html).

#### Declaration

```csharp
IEntityScroller CreateEntityScroller(Query query, TimeSpan? scrollTime = null, IEntityLoadConfiguration loadConfiguration = null)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| [Query](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.base.querying.query.html) | query | The query to scroll. |
| TimeSpan | scrollTime | The time for the scroll to live. If it is not specified, [ScrollTime](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.defaults.scrolling.html) will be used. The scroll time should not be too long, just enough to process each batch of results. |
| [IEntityLoadConfiguration](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.framework.essentials.loadconfigurations.ientityloadconfiguration.html) | loadConfiguration | The load configuration. If it is null, then [Default](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.framework.essentials.loadconfigurations.entityloadconfiguration.html) will be used. |

#### Returns

| Type | Description |
| --- | --- |
| [IEntityScroller](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.querying.ientityscroller.html) | An [IEntityScroller](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.querying.ientityscroller.html) instance. |

#### Remarks

Use scrolling wisely and try to limit the `scrollTime` for the scroll to live. Using scrolling inappropriately can cause performance issues. See [https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html) for more information.

### QueryAsync(Query, IEntityLoadConfiguration)

Retrieves entities matching the `query`.

#### Declaration

```csharp
Task<IEntityQueryResult> QueryAsync(Query query, IEntityLoadConfiguration loadConfiguration = null)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| [Query](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.base.querying.query.html) | query | The query to execute. |
| [IEntityLoadConfiguration](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.framework.essentials.loadconfigurations.ientityloadconfiguration.html) | loadConfiguration | The load configuration. If it is null, then [Default](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.framework.essentials.loadconfigurations.entityloadconfiguration.html) will be used. |

#### Returns

| Type | Description |
| --- | --- |
| Task<>[IEntityQueryResult](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.querying.ientityqueryresult.html) | An [IEntityQueryResult](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.querying.ientityqueryresult.html) containing the results of the query. |

#### Remarks

For compatibility with the 3.0 SDK, the loading configuration is resolved as follows:

1. The `loadConfiguration` will be used, if not null.
2. The [IQueryLoadConfiguration](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.framework.essentials.loadconfigurations.iqueryloadconfiguration.html) from the `query` will be used, if not null and if applicable.
3. Otherwise, defaults to [Default](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.framework.essentials.loadconfigurations.entityloadconfiguration.html).

### QueryIdsAsync(Query)

Retrieves the ids of entities matching the `query`.

#### Declaration

```csharp
Task<IIdQueryResult> QueryIdsAsync(Query query)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| [Query](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.base.querying.query.html) | query | The query to execute. |

#### Returns

| Type | Description |
| --- | --- |
| Task<>[IIdQueryResult](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.querying.iidqueryresult.html) | An [IEntityQueryResult](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.querying.ientityqueryresult.html) containing the results of the query. |

### SingleAsync(Query, IEntityLoadConfiguration)

Gets a single entity that matches the query.

#### Declaration

```csharp
Task<IEntity> SingleAsync(Query query, IEntityLoadConfiguration loadConfiguration = null)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| [Query](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.base.querying.query.html) | query | The query to execute. |
| [IEntityLoadConfiguration](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.framework.essentials.loadconfigurations.ientityloadconfiguration.html) | loadConfiguration | The load configuration. If it is null, then [Default](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.framework.essentials.loadconfigurations.entityloadconfiguration.html) will be used. |

#### Returns

| Type | Description |
| --- | --- |
| Task<>[IEntity](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientity.html) | The entity that matches the query or null if there are no results. |

#### Remarks

For compatibility with the 3.0 SDK, the loading configuration is resolved as follows:

1. The `loadConfiguration` will be used, if not null.
2. The [IQueryLoadConfiguration](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.framework.essentials.loadconfigurations.iqueryloadconfiguration.html) from the `query` will be used, if not null and if applicable.
3. Otherwise, defaults to [Default](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.framework.essentials.loadconfigurations.entityloadconfiguration.html).

### SingleIdAsync(Query)

Gets a the id of the entity that matches the query.

#### Declaration

```csharp
Task<long?> SingleIdAsync(Query query)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| [Query](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.base.querying.query.html) | query | The query to execute. |

#### Returns

| Type | Description |
| --- | --- |
| Task<>long | The id of the entity that matches the query or null if there are no results. |
