EntityKey Class
An EntityKey is an object that represents the unique identity of an entity. EntityKey's are immutable.
Methods
<ctor> EntityKey
-
entityType
-
keyValues
Constructs a new EntityKey. Each entity within an EntityManager will have a unique EntityKey.
Parameters:
-
entityType
EntityTypeThe EntityType of the entity.
-
keyValues
Value | Array of valuesA single value or an array of values.
Example:
// assume em1 is an EntityManager containing a number of existing entities.
var empType = em1.metadataStore.getEntityType("Employee");
var entityKey = new EntityKey(empType, 1);
EntityKey's may also be found by calling EntityAspect.getKey()
// assume employee1 is an existing Employee entity
var empKey = employee1.entityAspect.getKey();
Multipart keys are created by passing an array as the 'keyValues' parameter
var empTerrType = em1.metadataStore.getEntityType("EmployeeTerritory");
var empTerrKey = new EntityKey(empTerrType, [ 1, 77]);
// The order of the properties in the 'keyValues' array must be the same as that
// returned by empTerrType.keyProperties
equals
-
entityKey
Used to compare EntityKeys are determine if they refer to the same Entity. There is also an static version of 'equals' with the same functionality.
Parameters:
-
entityKey
EntityKey
Example:
// assume em1 is an EntityManager containing a number of existing entities.
var empType = em1.metadataStore.getEntityType("Employee");
var empKey1 = new EntityKey(empType, 1);
// assume employee1 is an existing Employee entity
var empKey2 = employee1.entityAspect.getKey();
if (empKey1.equals(empKey2)) {
// do something ...
}
equals
-
k1
-
k2
Used to compare EntityKeys are determine if they refer to the same Entity. There is also an instance version of 'equals' with the same functionality.
Example:
// assume em1 is an EntityManager containing a number of existing entities.
var empType = em1.metadataStore.getEntityType("Employee");
var empKey1 = new EntityKey(empType, 1);
// assume employee1 is an existing Employee entity
var empKey2 = employee1.entityAspect.getKey();
if (EntityKey.equals(empKey1, empKey2)) {
// do something ...
}
Properties
values
Array
An array of the values for this key. This will usually only have a single element, unless the entity type has a multipart key.
readOnly