Options
All
  • Public
  • Public/Protected
  • All
Menu

Class EntityType

Container for all of the metadata about a specific type of Entity.

Hierarchy

  • EntityType

Index

Constructors

constructor

  • EntityType constructor

     let entityType = new EntityType( {
         shortName: "person",
         namespace: "myAppNamespace"
     });
    

    Parameters

    • config: MetadataStore | EntityTypeConfig

      Configuration settings or a MetadataStore. If this parameter is just a MetadataStore then what will be created is an 'anonymous' type that will never be communicated to or from the server. It is purely for client side use and will be given an automatically generated name. Normally, however, you will use a configuration object.

    Returns EntityType

Properties

autoGeneratedKeyType

autoGeneratedKeyType: AutoGeneratedKeyType

The AutoGeneratedKeyType for this EntityType. Read Only

baseEntityType

baseEntityType: EntityType

The base EntityType (if any) for this EntityType. Read Only

Optional baseTypeName

baseTypeName: string

The name of this EntityType's base EntityType (if any)

complexProperties

complexProperties: DataProperty[]

The DataProperties for this EntityType that contain instances of a ComplexType. Read Only

concurrencyProperties

concurrencyProperties: DataProperty[]

The DataProperties associated with this EntityType that are concurrency properties. Read Only

Optional custom

custom: Object

A free form object that can be used to define any custom metadata for this EntityType. Read Only

dataProperties

dataProperties: DataProperty[]

The DataProperties (see DataProperty associated with this EntityType. Read Only

defaultResourceName

defaultResourceName: string

The default resource name associated with this EntityType. An EntityType may be queried via a variety of 'resource names' but this one is used as the default when no resource name is provided. This will occur when calling EntityAspect.loadNavigationProperty or when executing any EntityQuery that was created via an EntityKey. Read Only

foreignKeyProperties

foreignKeyProperties: DataProperty[]

The DataProperties associated with this EntityType that are foreign key properties. Read Only

getEntityCtor

getEntityCtor: getCtor = this.getCtor
deprecated

Use getCtor instead.

initFn

initFn: Function | string

inverseForeignKeyProperties

inverseForeignKeyProperties: DataProperty[]

isAbstract

isAbstract: boolean

Whether this EntityType is abstract. Read Only

isAnonymous

isAnonymous: boolean

Whether this EntityType is anonymous. Anonymous types will never be communicated to or from the server. They are purely for client side use and are given an automatically generated name. Read Only

isComplexType

isComplexType: boolean = false

Always false for an EntityType.

isFrozen

isFrozen: boolean

Whether this EntityType has been 'frozen'. EntityTypes become frozen after the first instance of that type has been created and attached to an EntityManager.

keyProperties

keyProperties: DataProperty[]

The DataProperties associated with this EntityType that make up it's EntityKey. Read Only

metadataStore

metadataStore: MetadataStore

The MetadataStore that contains this EntityType. Read Only

name

name: string

The fully qualified name of this EntityType. Read Only

namespace

namespace: string

The namespace for this EntityType. Read Only

navigationProperties

navigationProperties: NavigationProperty[]

The NavigationProperties (see NavigationProperty associated with this EntityType. Read Only

noTrackingFn

noTrackingFn: Function

Optional serializerFn

serializerFn: (prop: EntityProperty, val: any) => any

A function that is used to customize the serialization of any EntityProperties of this type.

Type declaration

shortName

shortName: string

The short, unqualified, name for this EntityType. Read Only

subtypes

subtypes: EntityType[]

unmappedProperties

unmappedProperties: DataProperty[]

The DataProperties associated with this EntityType that are not mapped to any backend datastore. These are effectively free standing properties. Read Only

validators

validators: Validator[]

The entity level validators associated with this EntityType. Validators can be added and removed from this collection. Read Only.

warnings

warnings: any[]

Methods

addProperty

addValidator

  • Adds either an entity or property level validator to this EntityType.

     // assume em1 is an EntityManager containing a number of existing entities.
     let custType = em1.metadataStore.getEntityType("Customer");
     let countryProp = custType.getProperty("Country");
     let valFn = function (v) {
             if (v == null) return true;
             return (core.stringStartsWith(v, "US"));
         };
     let countryValidator = new Validator("countryIsUS", valFn,
     { displayName: "Country", messageTemplate: "'%displayName%' must start with 'US'" });
     custType.addValidator(countryValidator, countryProp);
    

    This is the same as adding an entity level validator via the 'validators' property of DataProperty or NavigationProperty

     countryProp.validators.push(countryValidator);
    

    Entity level validators can also be added by omitting the 'property' parameter.

     custType.addValidator(someEntityLevelValidator);
    

    or

     custType.validators.push(someEntityLevelValidator);
    

    Parameters

    • validator: Validator

      Validator to add.

    • Optional property: EntityProperty | string

      Property to add this validator to. If omitted, the validator is assumed to be an entity level validator and is added to the EntityType's 'validators'.

    Returns void

clientPropertyPathToServer

  • clientPropertyPathToServer(propertyPath: string, delimiter?: string): string
  • For use in pluggable adapters.

    Parameters

    • propertyPath: string
    • Default value delimiter: string = "."

    Returns string

createEntity

  • createEntity(initialValues?: any): any
  • Create a new entity of this type.

     // assume em1 is an EntityManager containing a number of existing entities.
     let custType = em1.metadataStore.getAsEntityType("Customer");
     let cust1 = custType.createEntity();
     em1.addEntity(cust1);
    

    Parameters

    • Optional initialValues: any

    Returns any

    The new entity.

getAllValidators

getCtor

  • getCtor(forceRefresh?: boolean): { constructor: any }

getDataProperty

  • Returns a data property with the specified name or null.

     // assume em1 is an EntityManager containing a number of existing entities.
     let custType = em1.metadataStore.getEntityType("Customer");
     let customerNameDataProp = custType.getDataProperty("CustomerName");
    

    Parameters

    • propertyName: string

    Returns DataProperty

    A DataProperty or null if not found.

getEntityKeyFromRawEntity

  • getEntityKeyFromRawEntity(rawEntity: any, rawValueFn: Function): EntityKey

getNavigationProperty

  • Returns a navigation property with the specified name or null.

     // assume em1 is an EntityManager containing a number of existing entities.
     let custType = em1.metadataStore.getEntityType("Customer");
     let customerOrdersNavProp = custType.getDataProperty("Orders");
    

    Parameters

    • propertyName: string

    Returns NavigationProperty

    A NavigationProperty or null if not found.

getProperties

  • Returns all of the properties ( dataProperties and navigationProperties) for this EntityType.

     // assume em1 is an EntityManager containing a number of existing entities.
     let custType = em1.metadataStore.getEntityType("Customer");
     let arrayOfProps = custType.getProperties();
    

    Returns EntityProperty[]

    An array of Data and Navigation properties.

getProperty

  • getProperty(propertyPath: string, throwIfNotFound?: boolean): EntityProperty
  • Returns either a DataProperty or a NavigationProperty with the specified name or null.

    This method also accepts a '.' delimited property path and will return the 'property' at the end of the path.

     let custType = em1.metadataStore.getEntityType("Customer");
     let companyNameProp = custType.getProperty("CompanyName");
    

    This method can also walk a property path to return a property

     let orderDetailType = em1.metadataStore.getEntityType("OrderDetail");
     let companyNameProp2 = orderDetailType.getProperty("Order.Customer.CompanyName");
     // companyNameProp === companyNameProp2
    

    Parameters

    • propertyPath: string
    • Default value throwIfNotFound: boolean = false

    Returns EntityProperty

    A DataProperty or NavigationProperty or null if not found.

getPropertyNames

  • getPropertyNames(): any[]
  • Returns all of the property names ( for both dataProperties and navigationProperties) for this EntityType.

     // assume em1 is an EntityManager containing a number of existing entities.
     let custType = em1.metadataStore.getEntityType("Customer");
     let arrayOfPropNames = custType.getPropertyNames();
    

    Returns any[]

getSelfAndSubtypes

  • getSelfAndSubtypes(): this[]
  • Returns an array containing this type and any/all subtypes of this type down thru the hierarchy.

    Returns this[]

isSubtypeOf

setProperties

  • General purpose property set method

     // assume em1 is an EntityManager containing a number of existing entities.
     let custType = em1.metadataStore.getEntityType("Customer");
     custType.setProperties( {
         autoGeneratedKeyType: AutoGeneratedKeyType.Identity;
         defaultResourceName: "CustomersAndIncludedOrders"
     )};
    

    Parameters

    Returns void

toJSON

  • toJSON(): Object

toString

  • toString(): string

Generated using TypeDoc