---
title: "Interface IEntityDefinitionsClient"
slug: "sdk--stylelabs.m.sdk.clients.ientitydefinitionsclient"
abstract: ""
---
# Interface IEntityDefinitionsClient

Contains functionality to get entity definitions and their entities.

## Namespace: StylelabsStylelabs.MSdkClients

## Assembly: Stylelabs.M.Sdk.dll

## Syntax

```csharp
public interface IEntityDefinitionsClient
```

## Remarks

This client exposes a lot of methods that also have cached version. It is generally advised to use the cached variants.

## Methods

### CreateEntityDefinitionIdIterator(long)

Creates an iterator to iterate over all the available entity definition ids in the system. Results are ordered ascending by id.

#### Declaration

```csharp
IIdIterator CreateEntityDefinitionIdIterator(long pageSize = null)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| long | pageSize | The page size. |

#### Returns

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

### CreateEntityDefinitionIterator(long)

Creates an iterator to iterate over all the available [IEntityDefinition](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientitydefinition.html) instances in the system. Results are ordered ascending by id.

#### Declaration

```csharp
IEntityDefinitionIterator CreateEntityDefinitionIterator(long pageSize = null)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| long | pageSize | The page size. |

#### Returns

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

### DeleteAsync(long)

Deletes the entity definition in Content Hub. If the entity definition doesn't exist, nothing will happen.

#### Declaration

```csharp
Task DeleteAsync(long id)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| long | id | The id of the entity definition to delete. |

#### Returns

| Type | Description |
| --- | --- |
| Task | A representing the asynchronous operation. |

#### Exceptions

| Type | Condition |
| --- | --- |
| [ForbiddenException](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.exceptions.forbiddenexception.html) | Thrown when the entity definition exists but could not be deleted. |

### DeleteAsync(string)

Deletes the entity definition in Content Hub. If the entity definition doesn't exist, nothing will happen.

#### Declaration

```csharp
Task DeleteAsync(string name)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| string | name | The name of the entity definition to delete. |

#### Returns

| Type | Description |
| --- | --- |
| Task | A representing the asynchronous operation. |

#### Exceptions

| Type | Condition |
| --- | --- |
| [ForbiddenException](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.exceptions.forbiddenexception.html) | Thrown when the entity definition exists but could not be deleted. |

### GetAsync(long)

Gets the [IEntityDefinition](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientitydefinition.html) instance by the specified `id`.

#### Declaration

```csharp
Task<IEntityDefinition> GetAsync(long id)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| long | id | Entity definition id. |

#### Returns

| Type | Description |
| --- | --- |
| Task<>[IEntityDefinition](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientitydefinition.html) | The [IEntityDefinition](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientitydefinition.html) or null if the entity definition does not exist. |

### GetAsync(string)

Gets the [IEntityDefinition](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientitydefinition.html) instance by the specified `name`.

#### Declaration

```csharp
Task<IEntityDefinition> GetAsync(string name)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| string | name | Entity definition name (case insensitive). |

#### Returns

| Type | Description |
| --- | --- |
| Task<>[IEntityDefinition](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientitydefinition.html) | The [IEntityDefinition](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientitydefinition.html) or null if the entity definition does not exist. |

### GetCachedAsync(long)

Gets the cached [IEntityDefinition](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientitydefinition.html) instance by the specified `id`.

#### Declaration

```csharp
Task<IEntityDefinition> GetCachedAsync(long id)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| long | id | Entity definition id. |

#### Returns

| Type | Description |
| --- | --- |
| Task<>[IEntityDefinition](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientitydefinition.html) | The [IEntityDefinition](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientitydefinition.html) or null if the entity definition does not exist. |

### GetCachedAsync(string)

Gets the cached [IEntityDefinition](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientitydefinition.html) instance by the specified `name`.

#### Declaration

```csharp
Task<IEntityDefinition> GetCachedAsync(string name)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| string | name | Entity definition name (case insensitive). |

#### Returns

| Type | Description |
| --- | --- |
| Task<>[IEntityDefinition](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientitydefinition.html) | The [IEntityDefinition](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientitydefinition.html) or null if the entity definition does not exist. |

### GetIdAsync(string)

Gets the id of the specified entity definition.

#### Declaration

```csharp
Task<long?> GetIdAsync(string name)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| string | name | Entity definition name (case insensitive). |

#### Returns

| Type | Description |
| --- | --- |
| Task<>long | The entity definition id or null if the entity definition does not exist. |

### GetIdCachedAsync(string)

Gets the id of the specified cached entity definition.

#### Declaration

```csharp
Task<long?> GetIdCachedAsync(string name)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| string | name | Entity definition name (case insensitive). |

#### Returns

| Type | Description |
| --- | --- |
| Task<>long | The entity definition id or null if the entity definition does not exist. |

### GetIdsAsync(IEnumerable<string>)

Gets the entity definition ids by the names of the definitions.

#### Declaration

```csharp
Task<IDictionary<string, long>> GetIdsAsync(IEnumerable<string> names)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| IEnumerable<>string | names | Entity definition names (case insensitive). |

#### Returns

| Type | Description |
| --- | --- |
| Task<>IDictionary<, >stringlong | Non null, case-insensitive dictionary that maps the definition names to ids. |

### GetIdsCachedAsync(IEnumerable<string>)

Gets the cached entity definition ids by the names of the definitions.

#### Declaration

```csharp
Task<IDictionary<string, long>> GetIdsCachedAsync(IEnumerable<string> names)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| IEnumerable<>string | names | Entity definition names (case insensitive). |

#### Returns

| Type | Description |
| --- | --- |
| Task<>IDictionary<, >stringlong | Non null, case-insensitive dictionary that maps the definition names to ids. |

### GetManyAsync(IEnumerable<long>)

Gets the [IEntityDefinition](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientitydefinition.html) instances by the ids of the definitions. The result can have a different ordering and size (when definitions don't exist) than the input.

#### Declaration

```csharp
Task<IList<IEntityDefinition>> GetManyAsync(IEnumerable<long> ids)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| IEnumerable<>long | ids | The ids. |

#### Returns

| Type | Description |
| --- | --- |
| Task<>IList<>[IEntityDefinition](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientitydefinition.html) | Non null collection of [IEntityDefinition](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientitydefinition.html) instances. |

### GetManyAsync(IEnumerable<string>)

Gets the [IEntityDefinition](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientitydefinition.html) instances by the names of the definitions. The result can have a different ordering and size (when definitions don't exist) than the input.

#### Declaration

```csharp
Task<IList<IEntityDefinition>> GetManyAsync(IEnumerable<string> names)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| IEnumerable<>string | names | Entity definition names (case insensitive). |

#### Returns

| Type | Description |
| --- | --- |
| Task<>IList<>[IEntityDefinition](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientitydefinition.html) | Non null collection of [IEntityDefinition](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientitydefinition.html) instances. |

### GetManyCachedAsync(IEnumerable<long>)

Gets the cached [IEntityDefinition](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientitydefinition.html) instances by the ids of the definitions. The result can have a different ordering and size (when definitions don't exist) than the input.

#### Declaration

```csharp
Task<IList<IEntityDefinition>> GetManyCachedAsync(IEnumerable<long> ids)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| IEnumerable<>long | ids | The ids. |

#### Returns

| Type | Description |
| --- | --- |
| Task<>IList<>[IEntityDefinition](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientitydefinition.html) | Non null collection of [IEntityDefinition](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientitydefinition.html) instances. |

### GetManyCachedAsync(IEnumerable<string>)

Gets the cached [IEntityDefinition](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientitydefinition.html) instances by the names of the definitions. The result can have a different ordering and size (when definitions don't exist) than the input.

#### Declaration

```csharp
Task<IList<IEntityDefinition>> GetManyCachedAsync(IEnumerable<string> names)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| IEnumerable<>string | names | Entity definition names (case insensitive). |

#### Returns

| Type | Description |
| --- | --- |
| Task<>IList<>[IEntityDefinition](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientitydefinition.html) | Non null collection of [IEntityDefinition](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientitydefinition.html) instances. |

### GetManyIdsAsync(IEnumerable<string>)

Gets the entity definition ids by the names of the definitions. The ids have the same ordering as the `names`, except for definitions that were not found.

#### Declaration

```csharp
Task<IList<long>> GetManyIdsAsync(IEnumerable<string> names)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| IEnumerable<>string | names | Entity definition names (case insensitive). |

#### Returns

| Type | Description |
| --- | --- |
| Task<>IList<>long | Non null collection of entity definition ids. |

#### Remarks

It is recommended to use [GetIdsAsync(IEnumerable<string>)](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.clients.ientitydefinitionsclient.html) instead, because the mapping is much clearer.

### GetNameAsync(long)

Gets the name of the [IEntityDefinition](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientitydefinition.html) with the specified `id`.

#### Declaration

```csharp
Task<string> GetNameAsync(long id)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| long | id | The id of the definition to get the name of. |

#### Returns

| Type | Description |
| --- | --- |
| Task<>string | The name of the specified definition or null if it doesn't exist. |

### GetNameCachedAsync(long)

Gets the name of the cached [IEntityDefinition](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientitydefinition.html) with the specified `id`.

#### Declaration

```csharp
Task<string> GetNameCachedAsync(long id)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| long | id | The id of the definition to get the name of. |

#### Returns

| Type | Description |
| --- | --- |
| Task<>string | The name of the specified definition or null if it doesn't exist. |

### GetNamesAsync(IEnumerable<long>)

Gets the entity definition names by the ids of the definitions.

#### Declaration

```csharp
Task<IDictionary<long, string>> GetNamesAsync(IEnumerable<long> ids)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| IEnumerable<>long | ids | Entity definition ids. |

#### Returns

| Type | Description |
| --- | --- |
| Task<>IDictionary<, >longstring | Non null dictionary that maps the definition ids to names. |

### GetNamesCachedAsync(IEnumerable<long>)

Gets the cached entity definition names by the ids of the definitions.

#### Declaration

```csharp
Task<IDictionary<long, string>> GetNamesCachedAsync(IEnumerable<long> ids)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| IEnumerable<>long | ids | Entity definition ids. |

#### Returns

| Type | Description |
| --- | --- |
| Task<>IDictionary<, >longstring | Non null dictionary that maps the definition ids to names. |

### GetRangeAsync(long, long)

Gets a set of [IEntityDefinition](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientitydefinition.html) instances in the system by specified range. Results are ordered ascending by id.

#### Declaration

```csharp
Task<IEntityDefinitionQueryResult> GetRangeAsync(long skip = null, long take = null)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| long | skip | Skip specified number of entity definitions. If no value is specified, no items will be skipped. |
| long | take | Take only specified number of entity definitions. |

#### Returns

| Type | Description |
| --- | --- |
| Task<>[IEntityDefinitionQueryResult](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.querying.ientitydefinitionqueryresult.html) | A query result of entity definitions. |

### GetRangeIdsAsync(long, long)

Gets a set of entity definition ids in the system by specified range. Results are ordered ascending by id.

#### Declaration

```csharp
Task<IIdQueryResult> GetRangeIdsAsync(long skip = null, long take = null)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| long | skip | Skip specified number of entity definitions. If no value is specified, no items will be skipped. |
| long | take | Take only specified number of entity definitions. |

#### Returns

| Type | Description |
| --- | --- |
| Task<>[IIdQueryResult](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.querying.iidqueryresult.html) | A query result of entity definition ids. |

### SaveAsync(IEntityDefinition)

Saves the entity definition in Content Hub.

#### Declaration

```csharp
Task<long> SaveAsync(IEntityDefinition entityDefinition)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| [IEntityDefinition](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientitydefinition.html) | entityDefinition | The entity definition to save. |

#### Returns

| Type | Description |
| --- | --- |
| Task<>long | The id of the entity definition in Content Hub. |

#### Exceptions

| Type | Condition |
| --- | --- |
| [ValidationException](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.exceptions.validationexception.html) | Thrown when the entity definition could not be saved because a validation error occurred. |
