BreezeJS: Server added object showing as added in client after save changes

不羁岁月 提交于 2019-12-06 04:24:04

We were able to reproduce the problem and it is a bug. (The entity added on server should have returned to the client as an Unchanged entity) We are working on a fix.

===EDIT===

The BeforeSaveEntity method is called once for each entity to be saved and should only manipulate the entity in question. You can find more about this at http://www.breezejs.com/documentation/custom-efcontextprovider.

If you want to create more entities to be saved in the server, you should do so in the BeforeSaveEntities method, where you can also add them to the saveMap dictionary to ensure they are saved in the DB.

i.e.

protected override Dictionary<Type, List<EntityInfo>> BeforeSaveEntities(Dictionary<Type, List<EntityInfo>> saveMap) {
    Dictionary<Type, List<EntityInfo>> saveMapAdditions = new Dictionary<Type, List<EntityInfo>>();

    var prod = this.CreateEntityInfo(product, EntityState.Added);
    // add data to the entity
    saveMapAdditions[typeof(Product)].Add(prod);

    return base.BeforeSaveEntities(saveMap);
}

As of Breeze 1.3.5, available now, this has been fixed. and thanks for the repro...

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