Skip to main content
Version: 4.4.0

Working With the Entity Key

The IEntityKeyinterface

What is the IEntityKey interface?

All entities in iCore are represented by a unique entity key, accessible from the IEntity interface which is the base interface of all entities. The key is presented to the Workflow developer by the interface IEntityKey. Basically, an entity key is the entity ID (a Guid, or integer type) and an enumeration defining the type of the entity.

Why and when is IEntityKey used?

IEntityKey is used in some activities and some iCore Process Server Public API methods and properties.

In some circumstances, supplying the entity type information is an absolute requirement – it is simply not enough with only the ID of an entity. For example, when using the activity Get Custom Filtered Entities which returns a list of entities with different entity types. Those activities and APIs that do not need the information of the entity type uses only the ID of the entity. For example the Set Setting Attribute Value activity uses a Guid for identification of the Setting.

Examples of Workflow activities using an IEntityKey

There is one activity available to get instances of entity keys and this is the Get Filtered Keys activity. This activity executes an entity filter and returns a list of all matching entities. Example of an activity using IEntityKey as input is Get Entity From Key activity.

Examples using code expressions to create an IEntityKey

Below are some examples of how to get an IEntityKey using code expressions:

Look up a Setting and accessing the entity key

In this example we are using the Context class to get the entity key of a Setting with name "ScanDirectory".

iCore.LocalSystem.Context.System.Settings.GetByName("ScanDirectory").Key

Create an entity key from the ID of an entity

In this example we have a variable ("settingID") of type Guid. The content of the variable might have been set from outside, for example through the Event parameters.

iCore.LocalSystem.Context.System.CreateEntityKey(EntityType.Setting,settingID)

Get an instance of IEntity from an IEntityKey

In this example we have a variable ("settingKey") of type IEntityKey, this might have been retrieved from the Get Filtered Keys activity, and we are using that key to get an instance of the entity. To access the ISetting interface from the returned IEntity the type must be casted.

iCore.LocalSystem.Context.System.GetInstanceOfEntity(settingKey)