1. Stylelabs.M.Sdk.Models.Clients

Class EntitiesClientBase

Contains functionality to get and manipulate entities.

Inheritance

object

EntitiesClientBase

Implements

IEntitiesClient

Namespace: StylelabsStylelabs.MSdkStylelabs.M.Sdk.ModelsClients

Assembly: Stylelabs.M.Sdk.dll

Syntax

public abstract class EntitiesClientBase : IEntitiesClient

Remarks

When possible, always include the specific properties and relations that are required when fetching entities. IEntityLoadConfiguration

Constructors

EntitiesClientBase(IMClient)

Initializes a new instance of the EntitiesClientBase class.

Declaration

protected EntitiesClientBase(IMClient client)

Parameters

TypeNameDescription
IMClientclientThe client.

Methods

CopyAsync(long, IEntityCopyOptions)

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

Declaration

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

Parameters

TypeNameDescription
longentityIdThe source entity id.
IEntityCopyOptionscopyOptionsThe copy options.

Returns

TypeDescription
Task<>longThe id of the copied entity.

DeleteAsync(long)

Deletes the IEntity with the specified id in Content-Hub. If the entity doesn't exist, nothing will happen.

Declaration

public abstract Task DeleteAsync(long entityId)

Parameters

TypeNameDescription
longentityIdThe id of the entity to delete.

Returns

TypeDescription
TaskA representing the asynchronous operation.

Exceptions

TypeCondition
ForbiddenExceptionThrown when the entity exists but could not be deleted.

GetAsync(long, IEntityLoadConfiguration)

Gets the IEntity instance with the specified id.

Declaration

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

Parameters

TypeNameDescription
longidThe id of the entity to get.
IEntityLoadConfigurationloadConfigurationThe loading configuration for the entity.

Returns

TypeDescription
Task<>IEntityThe entity or null when it was not found.

GetAsync(string, IEntityLoadConfiguration)

Gets the IEntity instance with the specified identifier.

Declaration

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

Parameters

TypeNameDescription
stringidentifierThe identifier of the entity to get.
IEntityLoadConfigurationloadConfigurationThe loading configuration for the entity.

Returns

TypeDescription
Task<>IEntityThe entity or null when it was not found.

GetByDefinitionAsync(string, IEntityLoadConfiguration, int, int)

Queries for entities of the specified definition.

Declaration

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

Parameters

TypeNameDescription
stringdefinitionThe name of the definition to get the entities for (case insensitive).
IEntityLoadConfigurationloadConfigurationThe loading configuration for entity.
intskipSkip specified number of entities. If no value is specified, no items will be skipped.
inttakeTake only specified number of entities. If no value is specified, the default Take will be used.

Returns

TypeDescription
Task<>IEntityQueryResultThe iterator.

GetEntityIdIterator(string)

Creates an IIdIterator instance for the specified definition that returns entity ids Results are sorted ascending on creation date.

Declaration

public IIdIterator GetEntityIdIterator(string definition)

Parameters

TypeNameDescription
stringdefinitionThe name of the definition to get the entities for (case insensitive).

Returns

TypeDescription
IIdIteratorThe iterator.

GetEntityIterator(string, IEntityLoadConfiguration)

Creates an IEntityIterator instance for the specified definition that returns IEntity instances. Results are sorted ascending on creation date.

Declaration

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

Parameters

TypeNameDescription
stringdefinitionThe name of the definition to get the entities for (case insensitive).
IEntityLoadConfigurationloadConfigurationThe loading configuration for entity.

Returns

TypeDescription
IEntityIteratorThe iterator.

GetIdsByDefinitionAsync(string, int, int)

Queries for entity ids of the specified definition.

Declaration

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

Parameters

TypeNameDescription
stringdefinitionThe name of the definition to get the entities for (case insensitive).
intskipSkip specified number of entities. If no value is specified, no items will be skipped.
inttakeTake only specified number of entities. If no value is specified, the default Take will be used.

Returns

TypeDescription
Task<>IIdQueryResultThe iterator.

GetManyAsync(IEnumerable, IEntityLoadConfiguration)

Gets multiple IEntity instances with the specified ids. The result can have a different ordering and size (when entities don't exist) than the input.

Declaration

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

Parameters

TypeNameDescription
IEnumerable<>longidsThe ids of the entities to get.
IEntityLoadConfigurationloadConfigurationThe loading configuration for the entity.

Returns

TypeDescription
Task<>IList<>IEntityA (non-null) list of entities.

GetManyAsync(IEnumerable, IEntityLoadConfiguration)

Gets multiple IEntity instances with the specified s. The result can have a different ordering and size (when entities don't exist) than the input.

Declaration

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

Parameters

TypeNameDescription
IEnumerable<>stringidentifiersThe identifiers of the entities to get.
IEntityLoadConfigurationloadConfigurationThe loading configuration for the entity.

Returns

TypeDescription
Task<>IList<>IEntityA (non-null) list of entities.

SaveAsync(IEntity)

Saves the entity in Content-Hub.

Declaration

public abstract Task<long> SaveAsync(IEntity entity)

Parameters

TypeNameDescription
IEntityentityThe entity to save.

Returns

TypeDescription
Task<>longThe 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

TypeCondition
ValidationExceptionThrown when the entity could not be saved because a validation error occurred.

Implements

IEntitiesClient

If you have suggestions for improving this article, let us know!