Show:

EntityKey Class

Defined in: a30_entityKey.js:9
Module: breeze

An EntityKey is an object that represents the unique identity of an entity. EntityKey's are immutable.

Item Index

Methods

Properties

Methods

<ctor> EntityKey

(
  • entityType
  • keyValues
)

Defined in a30_entityKey.js:15

Constructs a new EntityKey. Each entity within an EntityManager will have a unique EntityKey.

Parameters:

  • entityType EntityType

    The EntityType of the entity.

  • keyValues Value | Array of values

    A 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
)

Defined in a30_entityKey.js:90

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:

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
)
static

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.

Parameters:

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

entityType

EntityType

Defined in a30_entityKey.js:64

The 'EntityType' that this is a key for.

readOnly

values

Array

Defined in a30_entityKey.js:71

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