Constructs a new EntityKey. Each entity within an EntityManager will have a unique EntityKey.
// 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
The EntityType of the entity.
A single value or an array of values.
The 'EntityType' that this is a key for. Read Only
An array of the values for this key. This will usually only have a single element, unless the entity type has a multipart key. Read Only
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.
// 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 ...
}
hidden
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.
// 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 ...
}
Generated using TypeDoc
An EntityKey is an object that represents the unique identity of an entity. EntityKey's are immutable.