build/breeze.debug.js
function EntityAspect(entity) {
    if (entity === null) {
      var nullInstance = EntityAspect._nullInstance;
      if (nullInstance) return nullInstance;
      EntityAspect._nullInstance = this;
    } else if (entity === undefined) {
      throw new Error("The EntityAspect ctor requires an entity as its only argument.");
    } else if (entity.entityAspect) {
      return entity.entityAspect;
    }

    // if called without new
    if (!(this instanceof EntityAspect)) {
      return new EntityAspect(entity);
    }

    this.entity = entity;
    // TODO: keep public or not?
    this.entityGroup = null;
    this.entityManager = null;
    this.entityState = EntityState.Detached;
    this.isBeingSaved = false;
    this.originalValues = {};
    this.hasValidationErrors = false;
    this._validationErrors = {};

    // Uncomment when we implement entityAspect.isNavigationPropertyLoaded method
    // this._loadedNavPropMap = {};

    this.validationErrorsChanged = new Event("validationErrorsChanged", this);
    this.propertyChanged = new Event("propertyChanged", this);
    // in case this is the NULL entityAspect. - used with ComplexAspects that have no parent.

    if (entity != null) {
      entity.entityAspect = this;
      // entityType should already be on the entity from 'watch'
      var entityType = entity.entityType || entity._$entityType;
      if (!entityType) {
        var typeName = entity.prototype._$typeName;
        if (!typeName) {
          throw new Error("This entity is not registered as a valid EntityType");
        } else {
          throw new Error("Metadata for this entityType has not yet been resolved: " + typeName);
        }
      }
      var entityCtor = entityType.getEntityCtor();
      __modelLibraryDef.getDefaultInstance().startTracking(entity, entityCtor.prototype);
    }
  }
function EntityAspect(entity) {
    if (entity === null) {
      var nullInstance = EntityAspect._nullInstance;
      if (nullInstance) return nullInstance;
      EntityAspect._nullInstance = this;
    } else if (entity === undefined) {
      throw new Error("The EntityAspect ctor requires an entity as its only argument.");
    } else if (entity.entityAspect) {
      return entity.entityAspect;
    }

    // if called without new
    if (!(this instanceof EntityAspect)) {
      return new EntityAspect(entity);
    }

    this.entity = entity;
    // TODO: keep public or not?
    this.entityGroup = null;
    this.entityManager = null;
    this.entityState = EntityState.Detached;
    this.isBeingSaved = false;
    this.originalValues = {};
    this.hasValidationErrors = false;
    this._validationErrors = {};

    // Uncomment when we implement entityAspect.isNavigationPropertyLoaded method
    // this._loadedNavPropMap = {};

    this.validationErrorsChanged = new Event("validationErrorsChanged", this);
    this.propertyChanged = new Event("propertyChanged", this);
    // in case this is the NULL entityAspect. - used with ComplexAspects that have no parent.

    if (entity != null) {
      entity.entityAspect = this;
      // entityType should already be on the entity from 'watch'
      var entityType = entity.entityType || entity._$entityType;
      if (!entityType) {
        var typeName = entity.prototype._$typeName;
        if (!typeName) {
          throw new Error("This entity is not registered as a valid EntityType");
        } else {
          throw new Error("Metadata for this entityType has not yet been resolved: " + typeName);
        }
      }
      var entityCtor = entityType.getEntityCtor();
      __modelLibraryDef.getDefaultInstance().startTracking(entity, entityCtor.prototype);
    }
  }
function EntityAspect ( entity ) { if ( entity === null ) { var nullInstance = EntityAspect . _nullInstance ; if ( nullInstance ) return nullInstance ; EntityAspect . _nullInstance = this ; } else if ( entity === undefined ) { throw new Error ( "The EntityAspect ctor requires an entity as its only argument." ) ; } else if ( entity . entityAspect ) { return entity . entityAspect ; } // if called without new if ( ! ( this instanceof EntityAspect ) ) { return new EntityAspect ( entity ) ; } this . entity = entity ; // TODO: keep public or not? this . entityGroup = null ; this . entityManager = null ; this . entityState = EntityState . Detached ; this . isBeingSaved = false ; this . originalValues = { } ; this . hasValidationErrors = false ; this . _validationErrors = { } ; // Uncomment when we implement entityAspect.isNavigationPropertyLoaded method // this._loadedNavPropMap = {}; this . validationErrorsChanged = new Event ( "validationErrorsChanged" , this ) ; this . propertyChanged = new Event ( "propertyChanged" , this ) ; // in case this is the NULL entityAspect. - used with ComplexAspects that have no parent. if ( entity != null ) { entity . entityAspect = this ; // entityType should already be on the entity from 'watch' var entityType = entity . entityType || entity . _$entityType ; if ( ! entityType ) { var typeName = entity . prototype . _$typeName ; if ( ! typeName ) { throw new Error ( "This entity is not registered as a valid EntityType" ) ; } else { throw new Error ( "Metadata for this entityType has not yet been resolved: " + typeName ) ; } } var entityCtor = entityType . getEntityCtor ( ) ; __modelLibraryDef . getDefaultInstance ( ) . startTracking ( entity , entityCtor . prototype ) ; } }
An EntityAspect instance is associated with every attached entity and is accessed via the entity's 'entityAspect' property.

The EntityAspect itself provides properties to determine and modify the EntityState of the entity and has methods
that provide a variety of services including validation and change tracking.

An EntityAspect will almost never need to be constructed directly. You will usually get an EntityAspect by accessing
an entities 'entityAspect' property.  This property will be automatically attached when an entity is created via either
a query, import or EntityManager.createEntity call.
@example
assume order is an order entity attached to an EntityManager.
var aspect = order.entityAspect;
var currentState = aspect.entityState;
@class EntityAspect
An EntityAspect instance is associated with every attached entity and is accessed via the entity s entityAspect property .