breezejs: calling savecChanges for a classic ODATA service fails

只谈情不闲聊 提交于 2019-11-28 09:48:39

问题


I'm trying to save an Entity that was loaded using a classic WEBAPI ODATA service.

When saveChanges is called on the client side, the modified entity is found and then the code goes into ´createChangeRequests´ and because the entityState is modified it goes into the function :

 function updateDeleteMergeRequest(request, aspect, prefix) {
    var extraMetadata = aspect.extraMetadata;
    var uri = extraMetadata.uri;
    if (__stringStartsWith(uri, prefix)) {
        uri = uri.substring(prefix.length);
    }
    request.requestUri = uri;
    if (extraMetadata.etag) {
        request.headers["If-Match"] = extraMetadata.etag;
    }
}

However it raises an exception on the second line because extraMetadata is null. Where is this supposed to come from ? The property extraMetadata does not even exist on 'aspect'....

breeze does have metadata of my model since I can load entities. It's just that I cannot save.


回答1:


line 13318(breeze.debug.js):

    function mergeEntity(node, mappingContext, meta) {
      node._$meta = meta;
      meta.extra = node.__metadata;//added
      var em = mappingContext.entityManager;



回答2:


I just stumpled across the same problem with Breeze 1.4.13. I resolved the problem by adding meta.extraMetadata = node.__metadata in line 14396

function mergeEntity(mc, node, meta) {
    node._$meta = meta;
    meta.extraMetadata = node.__metadata;
    var em = mc.entityManager;


来源:https://stackoverflow.com/questions/18513334/breezejs-calling-savecchanges-for-a-classic-odata-service-fails

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