Breeze named saves do not work as expected

时光怂恿深爱的人放手 提交于 2019-12-11 14:02:18

问题



I tried to use the named saves as below and as explained in the release notes here, but it dosen't work and returns:

Uncaught Error: The 'entities' parameter is optional or it must be an array where each element must be an entity => breeze.debug.js:724
proto.check => breeze.debug.js:724
proto.saveChanges => breeze.debug.js:11150
sendEmail

The function is:

var sendEmail = function () {
        var option = new breeze.SaveOptions({ resourceName: 'sendMail'})
        return manager.saveChanges({ saveOptions: option })
            .then(saveSucceeded)
            .fail(saveFailed);

        function saveSucceeded(saveResult) {
            log('La email è stata invata.', saveResult, true);
        }

        function saveFailed(error) {
            var msg = 'Invio della email è fallito: ' + getErrorMessages(error);
            logError(msg, error);
            error.message = msg;
            throw error;
        }
    };

Any help appretiated!


回答1:


The writeup in the release notes has the wrong syntax. I will have it fixed.

The first arg to EntityManager.saveChanges is always a list of entities, or it can be null to indicate all entities. The 2nd arg is an optional SaveOptions instance. See here. So your expression should be

  var option = new breeze.SaveOptions({ resourceName: 'sendMail'})
  return manager.saveChanges(null, option)


来源:https://stackoverflow.com/questions/16421404/breeze-named-saves-do-not-work-as-expected

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