Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If a save operation fails then the client side state will still be either "added", "modified" or "deleted". Changes are only accepted if a save succeeds. This allows you to "resave" the same entity or entities after you have "corrected" the issue without having to reassemble the changes.</p> <p>You can also use Breeze <em>EntityAspect.rejectChanges</em> to return an entity to its state when it was last queried. </p> <p>The simplest way to copy an entity is to use the Breeze <em>EntityManager.createEntity</em> method and pass in an object that contains just the data properties from the source entity. The reason this will work is that Breeze will automatically link up all of the navigation properties for you based on the foreign key data properties once the new entity is attached to the entityManager, which occurs internally as the last step of the createEntity call. </p> <p>So you might try something like this ( I didn't actually test this code fragment but this approach definitely does work. </p> <pre><code>function cloneEntity(sourceEntity, keyName, newKeyValue) { var sourceEntityType = sourceEntity.entityType; var sourceDataProperties = sourceEntityType.dataProperties; var configEntity = {}; sourceDataProperties.forEach(function(dp) { configEntity[dp.name] = sourceEntity.getProperty(dp.name); }); // you will need to give the entity a unique key before calling createEntity // you could also get the keyName from metadata but I was too lazy to do that here. configEntity[keyName] = newKeyValue; var cloneEntity = myEntityManager.createEntity(fooEntityType, configEntity, breeze.EntityState.Added); return cloneEntity; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload