---
title: "Class EntitiesClientBase"
slug: "sdk--stylelabs.m.sdk.models.clients.entitiesclientbase"
abstract: ""
---
# Class EntitiesClientBase

Contains functionality to get and manipulate entities.

## Inheritance

object

EntitiesClientBase

## Implements

[IEntitiesClient](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.clients.ientitiesclient.html)

## Namespace: StylelabsStylelabs.MSdkStylelabs.M.Sdk.ModelsClients

## Assembly: Stylelabs.M.Sdk.dll

## Syntax

```csharp
public abstract class EntitiesClientBase : IEntitiesClient
```

## Remarks

When possible, always include the specific properties and relations that are required when fetching entities. [IEntityLoadConfiguration](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.framework.essentials.loadconfigurations.ientityloadconfiguration.html)

## Constructors

### EntitiesClientBase(IMClient)

Initializes a new instance of the [EntitiesClientBase](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.models.clients.entitiesclientbase.html) class.

#### Declaration

```csharp
protected EntitiesClientBase(IMClient client)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| [IMClient](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.imclient.html) | client | The client. |

## Methods

### CopyAsync(long, IEntityCopyOptions)

Copies an entity by id to a new or existing entity.

#### Declaration

```csharp
public abstract Task<long> CopyAsync(long entityId, IEntityCopyOptions copyOptions)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| long | entityId | The source entity id. |
| [IEntityCopyOptions](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.models.content.ientitycopyoptions.html) | copyOptions | The copy options. |

#### Returns

| Type | Description |
| --- | --- |
| Task<>long | The id of the copied entity. |

### DeleteAsync(long)

Deletes the [IEntity](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientity.html) with the specified id in Content-Hub. If the entity doesn't exist, nothing will happen.

#### Declaration

```csharp
public abstract Task DeleteAsync(long entityId)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| long | entityId | The id of the entity 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 exists but could not be deleted. |

### GetAsync(long, IEntityLoadConfiguration)

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

#### Declaration

```csharp
public abstract Task<IEntity> GetAsync(long id, IEntityLoadConfiguration loadConfiguration = null)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| long | id | The id of the entity to get. |
| [IEntityLoadConfiguration](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.framework.essentials.loadconfigurations.ientityloadconfiguration.html) | loadConfiguration | The loading configuration for the entity. |

#### Returns

| Type | Description |
| --- | --- |
| Task<>[IEntity](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientity.html) | The entity or null when it was not found. |

### GetAsync(string, IEntityLoadConfiguration)

Gets the [IEntity](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientity.html) instance with the specified `identifier`.

#### Declaration

```csharp
public abstract Task<IEntity> GetAsync(string identifier, IEntityLoadConfiguration loadConfiguration = null)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| string | identifier | The identifier of the entity to get. |
| [IEntityLoadConfiguration](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.framework.essentials.loadconfigurations.ientityloadconfiguration.html) | loadConfiguration | The loading configuration for the entity. |

#### Returns

| Type | Description |
| --- | --- |
| Task<>[IEntity](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientity.html) | The entity or null when it was not found. |

### GetByDefinitionAsync(string, IEntityLoadConfiguration, int, int)

Queries for entities of the specified definition.

#### Declaration

```csharp
public Task<IEntityQueryResult> GetByDefinitionAsync(string definition, IEntityLoadConfiguration loadConfiguration = null, int skip = null, int take = null)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| string | definition | The name of the definition to get the entities for (case insensitive). |
| [IEntityLoadConfiguration](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.framework.essentials.loadconfigurations.ientityloadconfiguration.html) | loadConfiguration | The loading configuration for entity. |
| int | skip | Skip specified number of entities. If no value is specified, no items will be skipped. |
| int | take | Take only specified number of entities. If no value is specified, the default [Take](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.defaults.entities.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) | The iterator. |

### GetEntityIdIterator(string)

Creates an [IIdIterator](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.querying.iiditerator.html) instance for the specified `definition` that returns entity ids Results are sorted ascending on creation date.

#### Declaration

```csharp
public IIdIterator GetEntityIdIterator(string definition)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| string | definition | The name of the definition to get the entities for (case insensitive). |

#### Returns

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

### GetEntityIterator(string, IEntityLoadConfiguration)

Creates an [IEntityIterator](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.querying.ientityiterator.html) instance for the specified `definition` that returns [IEntity](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientity.html) instances. Results are sorted ascending on creation date.

#### Declaration

```csharp
public IEntityIterator GetEntityIterator(string definition, IEntityLoadConfiguration loadConfiguration = null)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| string | definition | The name of the definition to get the entities for (case insensitive). |
| [IEntityLoadConfiguration](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.framework.essentials.loadconfigurations.ientityloadconfiguration.html) | loadConfiguration | The loading configuration for entity. |

#### Returns

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

### GetIdsByDefinitionAsync(string, int, int)

Queries for entity ids of the specified definition.

#### Declaration

```csharp
public Task<IIdQueryResult> GetIdsByDefinitionAsync(string definition, int skip = null, int take = null)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| string | definition | The name of the definition to get the entities for (case insensitive). |
| int | skip | Skip specified number of entities. If no value is specified, no items will be skipped. |
| int | take | Take only specified number of entities. If no value is specified, the default [Take](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.defaults.entities.html) will be used. |

#### Returns

| Type | Description |
| --- | --- |
| Task<>[IIdQueryResult](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.querying.iidqueryresult.html) | The iterator. |

### GetManyAsync(IEnumerable<long>, IEntityLoadConfiguration)

Gets multiple [IEntity](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientity.html) instances with the specified `ids`. The result can have a different ordering and size (when entities don't exist) than the input.

#### Declaration

```csharp
public abstract Task<IList<IEntity>> GetManyAsync(IEnumerable<long> ids, IEntityLoadConfiguration loadConfiguration = null)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| IEnumerable<>long | ids | The ids of the entities to get. |
| [IEntityLoadConfiguration](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.framework.essentials.loadconfigurations.ientityloadconfiguration.html) | loadConfiguration | The loading configuration for the entity. |

#### Returns

| Type | Description |
| --- | --- |
| Task<>IList<>[IEntity](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientity.html) | A (non-null) list of entities. |

### GetManyAsync(IEnumerable<string>, IEntityLoadConfiguration)

Gets multiple [IEntity](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientity.html) instances with the specified s. The result can have a different ordering and size (when entities don't exist) than the input.

#### Declaration

```csharp
public Task<IList<IEntity>> GetManyAsync(IEnumerable<string> identifiers, IEntityLoadConfiguration loadConfiguration = null)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| IEnumerable<>string | identifiers | The identifiers of the entities to get. |
| [IEntityLoadConfiguration](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.framework.essentials.loadconfigurations.ientityloadconfiguration.html) | loadConfiguration | The loading configuration for the entity. |

#### Returns

| Type | Description |
| --- | --- |
| Task<>IList<>[IEntity](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.contracts.base.ientity.html) | A (non-null) list of entities. |

### SaveAsync(IEntity)

Saves the entity in Content-Hub.

#### Declaration

```csharp
public abstract Task<long> SaveAsync(IEntity entity)
```

#### Parameters

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

#### Returns

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

#### Remarks

The existing `entity` will not be updated in any way. If any information is needed that was generated on the server after persisting, they entity will need to be fetched again.

#### Exceptions

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

### Implements

[IEntitiesClient](https://doc.sitecore.com/ch/en/developers/api-reference/sdk--stylelabs.m.sdk.clients.ientitiesclient.html)
