Options
All
  • Public
  • Public/Protected
  • All
Menu

Class EntityKey

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

Hierarchy

  • EntityKey

Index

Constructors

constructor

  • 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
    

    Parameters

    • entityType: EntityType

      The EntityType of the entity.

    • keyValues: any

      A single value or an array of values.

    Returns EntityKey

Properties

entityType

entityType: EntityType

The 'EntityType' that this is a key for. Read Only

values

values: any[]

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

Methods

equals

  • 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  ...
     }
    

    Parameters

    Returns boolean

toJSON

  • toJSON(): { entityType: string; values: any[] }
  • Returns { entityType: string; values: any[] }

    • entityType: string
    • values: any[]

toString

Static createKeyString

  • createKeyString(keyValues: any[]): string

Static equals

  • 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  ...
     }
    

    Parameters

    Returns boolean

Static fromJSON

Generated using TypeDoc