What is the right way to append entity from one manager to another in breeze?

本秂侑毒 提交于 2019-12-10 12:13:39

问题


What is the right way to append entity from one manager to another? Straight forward attempts result in overwriting entities or in warning about the same entity key...

var entity = em1.getEntities()[0];
em1.deattachEntity(entity);

// assume em2 already has entities
em2.attachEntity(entity);

I believe there should be some in-build functionality for appending entries to another non empty manager or for generating an unique key for selected manager.

Any suggestions?

UPDATE:
I did read the documentation and tried to do it via exportEntities and exportEntities:

    var entity = em1.getEntities()[0];
    var export = em1.exportEntities([entity], false);
//here em2 already has entity with the same key as entity that I want to add
    var import = em2.importEntities(export, { mergeStrategy: breeze.MergeStrategy.Disallowed });

This gives me an error: A MergeStrategy of 'Disallowed' prevents Picture:#Macaw.Whitelabel.WebAPI.Models--1 from being merged

I really don't understand how to append entities....

UPDATE2: I did discover that manually assigning id of the attached entity solves the problem and error disappears. Is there a way to make it not manually but using breeze?

来源:https://stackoverflow.com/questions/23914060/what-is-the-right-way-to-append-entity-from-one-manager-to-another-in-breeze

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!