A BreezeEvent that fires whenever a value of one of this entity's properties change.
A BreezeEvent that fires whenever any of the validation errors on this entity change. Note that this might be the removal of an error when some data on the entity is fixed.
The Entity that this aspect is associated with. Read Only
The EntityManager that contains this entity. Read Only
The EntityState of this entity. Read Only
Extra metadata about this entity such as the entity's etag. You may extend this object with your own metadata information. Breeze (de)serializes this object when importing/exporting the entity.
Whether this entity has a temporary EntityKey.
Whether this entity has any validation errors. Read Only
Whether this entity is in the process of being saved. Read Only
The 'original values' of this entity where they are different from the 'current values'. This is a map where the key is a property name and the value is the 'original value' of the property.
Whether this entity was created by being loaded from the database
Returns the entity to an EntityState of 'Unchanged' by committing all changes made since the entity was last queried had 'acceptChanges' called on it.
// assume order is an order entity attached to an EntityManager.
order.entityAspect.acceptChanges();
// The 'order' entity will now be in an 'Unchanged' state with any changes committed.
Adds a validation error.
Removes all of the validation errors for a specified entity
Returns the EntityKey for this Entity.
// assume order is an order entity attached to an EntityManager.
var entityKey = order.entityAspect.getKey();
(boolean=false) Forces the recalculation of the key. This should normally be unnecessary.
The EntityKey associated with this Entity.
Returns an EntityKey for the entity pointed to by the specified scalar NavigationProperty. This only returns an EntityKey if the current entity is a 'child' entity along the specified NavigationProperty. i.e. has a single parent.
The NavigationProperty ( pointing to a parent).
Either a parent EntityKey if this is a 'child' entity or null;
Returns the value of a specified DataProperty or NavigationProperty or 'property path'.
Returns the validation errors associated with either the entire entity or any specified property.
This method can return all of the errors for an Entity
// assume order is an order entity attached to an EntityManager.
var valErrors = order.entityAspect.getValidationErrors();
as well as those for just a specific property.
// assume order is an order entity attached to an EntityManager.
var orderDateErrors = order.entityAspect.getValidationErrors("OrderDate");
which can also be expressed as
// assume order is an order entity attached to an EntityManager.
var orderDateProperty = order.entityType.getProperty("OrderDate");
var orderDateErrors = order.entityAspect.getValidationErrors(orderDateProperty);
A array of validation errors.
Returns the validation errors associated with either the entire entity or any specified property.
This method can return all of the errors for an Entity
// assume order is an order entity attached to an EntityManager.
var valErrors = order.entityAspect.getValidationErrors();
as well as those for just a specific property.
// assume order is an order entity attached to an EntityManager.
var orderDateErrors = order.entityAspect.getValidationErrors("OrderDate");
which can also be expressed as
// assume order is an order entity attached to an EntityManager.
var orderDateProperty = order.entityType.getProperty("OrderDate");
var orderDateErrors = order.entityAspect.getValidationErrors(orderDateProperty);
A array of validation errors.
Returns the validation errors associated with either the entire entity or any specified property.
This method can return all of the errors for an Entity
// assume order is an order entity attached to an EntityManager.
var valErrors = order.entityAspect.getValidationErrors();
as well as those for just a specific property.
// assume order is an order entity attached to an EntityManager.
var orderDateErrors = order.entityAspect.getValidationErrors("OrderDate");
which can also be expressed as
// assume order is an order entity attached to an EntityManager.
var orderDateProperty = order.entityType.getProperty("OrderDate");
var orderDateErrors = order.entityAspect.getValidationErrors(orderDateProperty);
A array of validation errors.
Determines whether a navigationProperty on this entity has already been loaded.
A navigation property is considered loaded when any of the following three conditions applies:
var wasLoaded = emp.entityAspect.isNavigationPropertyLoaded("Orders");
The NavigationProperty or name of NavigationProperty to 'load'.
Determines whether a navigationProperty on this entity has already been loaded.
A navigation property is considered loaded when any of the following three conditions applies:
var wasLoaded = emp.entityAspect.isNavigationPropertyLoaded("Orders");
Performs a query for the value of a specified NavigationProperty. Async
emp.entityAspect.loadNavigationProperty("Orders").then(function (data) {
var orders = data.results;
}).catch(function (exception) {
// handle exception here;
});
The NavigationProperty or the name of the NavigationProperty to 'load'.
Function to call on success.
Function to call on failure.
Promise with shape
Performs a query for the value of a specified NavigationProperty. Async
emp.entityAspect.loadNavigationProperty("Orders").then(function (data) {
var orders = data.results;
}).catch(function (exception) {
// handle exception here;
});
Promise with shape
Marks this navigationProperty on this entity as already having been loaded.
emp.entityAspect.markNavigationPropertyAsLoaded("Orders");
The NavigationProperty or name of NavigationProperty to 'load'.
Returns the entity to an EntityState of 'Unchanged' by rejecting all changes made to it since the entity was last queried had 'rejectChanges' called on it.
// assume order is an order entity attached to an EntityManager.
order.entityAspect.rejectChanges();
// The 'order' entity will now be in an 'Unchanged' state with any changes rejected.
Removes a validation error.
Removes a validation error.
Sets the entity to an EntityState of 'Added'. This is NOT the equivalent of calling EntityManager.addEntity because no key generation will occur for autogenerated keys as a result of this operation. As a result this operation can be problematic unless you are certain that the entity being marked 'Added' does not already exist in the database and does not have an autogenerated key. The same operation can be performed by calling EntityAspect.setEntityState.
// assume order is an order entity attached to an EntityManager.
order.entityAspect.setAdded();
// The 'order' entity will now be in an 'Added' state.
Sets the entity to an EntityState of 'Deleted'. This both marks the entity as being scheduled for deletion during the next 'Save' call but also removes the entity from all of its related entities. The same operation can be performed by calling EntityAspect.setEntityState.
// assume order is an order entity attached to an EntityManager.
order.entityAspect.setDeleted();
// The 'order' entity will now be in a 'Deleted' state and it will no longer have any 'related' entities.
Sets the entity to an EntityState of 'Detached'. This removes the entity from all of its related entities, but does NOT change the EntityState of any existing entities. The same operation can be performed by calling EntityAspect.setEntityState.
// assume order is an order entity attached to an EntityManager.
order.entityAspect.setDetached();
// The 'order' entity will now be in a 'Detached' state and it will no longer have any 'related' entities.
Sets the entity to the specified EntityState. See also 'setUnchanged', 'setModified', 'setDetached', etc.
// assume order is an order entity attached to an EntityManager.
order.entityAspect.setEntityState(EntityState.Unchanged);
// The 'order' entity will now be in a 'Unchanged' state.
Sets the entity to an EntityState of 'Modified'. This can also be achieved by changing the value of any property on an 'Unchanged' entity. The same operation can be performed by calling EntityAspect.setEntityState.
// assume order is an order entity attached to an EntityManager.
order.entityAspect.setModified();
// The 'order' entity will now be in a 'Modified' state.
Sets the entity to an EntityState of 'Unchanged'. This is also the equivalent of calling EntityAspect.acceptChanges. The same operation can be performed by calling EntityAspect.setEntityState.
// assume order is an order entity attached to an EntityManager.
order.entityAspect.setUnchanged();
// The 'order' entity will now be in an 'Unchanged' state with any changes committed.
Performs validation on the entity, any errors encountered during the validation are available via the EntityAspect.getValidationErrors method. Validating an entity means executing all of the validators on both the entity itself as well as those on each of its properties.
// assume order is an order entity attached to an EntityManager.
var isOk = order.entityAspect.validateEntity();
// isOk will be 'true' if there are no errors on the entity.
if (!isOk) {
var errors = order.entityAspect.getValidationErrors();
}
Whether the entity passed validation.
Performs validation on a specific property of this entity, any errors encountered during the validation are available via the EntityAspect.getValidationErrors method. Validating a property means executing all of the validators on the specified property. This call is also made automatically anytime a property of an entity is changed.
// assume order is an order entity attached to an EntityManager.
var isOk = order.entityAspect.validateProperty("Order");
or
var orderDateProperty = order.entityType.getProperty("OrderDate");
var isOk = order.entityAspect.validateProperty(OrderDateProperty);
The DataProperty or NavigationProperty to validate or a string with the name of the property or a property path with the path to a property of a complex object.
A context object used to pass additional information to each Validator.
Whether the entity passed validation.
Performs validation on a specific property of this entity, any errors encountered during the validation are available via the EntityAspect.getValidationErrors method. Validating a property means executing all of the validators on the specified property. This call is also made automatically anytime a property of an entity is changed.
// assume order is an order entity attached to an EntityManager.
var isOk = order.entityAspect.validateProperty("Order");
or
var orderDateProperty = order.entityType.getProperty("OrderDate");
var isOk = order.entityAspect.validateProperty(OrderDateProperty);
Whether the entity passed validation.
Performs validation on a specific property of this entity, any errors encountered during the validation are available via the EntityAspect.getValidationErrors method. Validating a property means executing all of the validators on the specified property. This call is also made automatically anytime a property of an entity is changed.
// assume order is an order entity attached to an EntityManager.
var isOk = order.entityAspect.validateProperty("Order");
or
var orderDateProperty = order.entityType.getProperty("OrderDate");
var isOk = order.entityAspect.validateProperty(OrderDateProperty);
Whether the entity passed validation.
Returns the value of a specified 'property path' for a specified entity.
The propertyPath can be either a string delimited with '.' or a string array.
Generated using TypeDoc
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.