This breeze documentation page has this sample for making a copy of an EntityManager:
function createManager() {
// same configuration; no entities in cache.
var manager = masterManager.createEmptyCopy();
// ... copy in some entities (e.g.,picklists) from masterManager
return manager;
}
I am not sure how I am supposed to do the "copy in some entities (e.g.,picklists) from masterManager
" step.
I guess I could just go create the entities as if they are new. But they are not, they are picklist values that were queried from the database.
I thought about trying to use Export/Import, but that seems like it is intended for offline work and serializes all the values to string. (Which seems like it may not be as performant as what I would like.)
Is there "normal" way that everyone copies entities between EntityManagers?
Yes, you copy the entities by exporting and importing. For performance, you should specify
asString: false
, to avoid string serialization overhead, andincludeMetadata: false
, since createEmptyCopy()
creates an EntityManager
that already has metadataSo:
function createManager() {
// same configuration; no entities in cache.
var manager = masterManager.createEmptyCopy();
var entities = masterManager.exportEntities(null, { asString: false, includeMetadata: false });
manager.importEntities(entities);
return manager;
}