MCPcopy Create free account
hub / github.com/DanWahlin/CustomerManagerStandard / checkEntityKey

Function checkEntityKey

CustomerManager/Scripts/breeze.debug.js:14503–14521  ·  view source on GitHub ↗
(em, entity)

Source from the content-addressed store, hash-verified

14501 }
14502
14503 function checkEntityKey(em, entity) {
14504 var ek = entity.entityAspect.getKey();
14505 // return properties that are = to defaultValues
14506 var keyPropsWithDefaultValues = __arrayZip(entity.entityType.keyProperties, ek.values, function (kp, kv) {
14507 return (kp.defaultValue === kv) ? kp : null;
14508 }).filter(function (kp) {
14509 return kp !== null;
14510 });
14511 if (keyPropsWithDefaultValues.length) {
14512 if (entity.entityType.autoGeneratedKeyType !== AutoGeneratedKeyType.None) {
14513 em.generateTempKeyValue(entity);
14514 } else {
14515 // we will allow attaches of entities where only part of the key is set.
14516 if (keyPropsWithDefaultValues.length === ek.values.length) {
14517 throw new Error("Cannot attach an object of type (" + entity.entityType.name + ") to an EntityManager without first setting its key or setting its entityType 'AutoGeneratedKeyType' property to something other than 'None'");
14518 }
14519 }
14520 }
14521 }
14522
14523 function validateEntityStates(em, entityStates) {
14524 if (!entityStates) return null;

Callers 1

breeze.debug.jsFile · 0.85

Calls 1

__arrayZipFunction · 0.85

Tested by

no test coverage detected