Entities client

The SDK provides an Entities client to perform CRUD operations on entities.

Get entities

The following method gets an entity by ID:

RequestResponse

IEntity entity = await MClient.Entities.GetAsync(entityId);

When the entity does not exist or the user does not have enough permissions to read it, the method returns null.

Note

There are many options to load entities by ID, by identifier or by definition.

Note

It is possible to pass loading configurations when loading entities. For more information about loading configurations, please refer to the load configurations section.

Create entities

You can create an entity only with the EntityFactory method.

In the following snippet, an Asset entity is created locally.

RequestResponse

IEntity asset = await MClient.EntityFactory.CreateAsync("M.Asset");

In the following snippet, the locally created Asset entity is sent to the server to be validated and persisted.

RequestResponse

long id = await MClient.Entities.SaveAsync(asset);

The returned ID is the ID of the newly created entity. To get the latest version of this entity, use the ID to get it from the server again.

Update entities

Similar to creating entities, use the save method on the entities client after making a change.

RequestResponse

long id = await MClient.Entities.SaveAsync(asset);

The returned id is the same ID of the entity. To get the latest version of this entity, use the ID to get it from the server again.

Delete entities

You can delete an entity with the Delete method and the entity ID.

RequestResponse

await MClient.Entities.DeleteAsync(entityId);

Do you have some feedback for us?

If you have suggestions for improving this article,