0

我有一个批量插入屏幕,允许用户逐行插入产品。每个产品都有自己的测量单位。

这是我的保存更改代码:

save = function (product) {
var entitiesToSave = product.units().slice();

entitiesToSave.push(product);

var so = new breeze.SaveOptions({ allowConcurrentSaves: true })
            return manager.saveChanges([entitiesToSave],so)
                    .then(saveSucceeded)
                    .fail(saveFailed);
}

一旦我尝试保存;我收到这条消息:

'entities' 参数是可选的,或者它必须是一个数组,其中每个元素都必须是一个实体

将代码修改为:

save = function (product) {
var so = new breeze.SaveOptions({ allowConcurrentSaves: true })
            return manager.saveChanges([product,product.units()[0]],so)
                    .then(saveSucceeded)
                    .fail(saveFailed);
}

适用于一个产品单元。但是,我需要一次性保存一个包含所有单元的特定产品。感谢任何帮助。

4

1 回答 1

2

对于那些可能有类似问题的人;我通过将代码修改为以下内容来修复它:

save = function (product) {
var entitiesToSave = new Array(product);

product.Units().forEach(function (Unit) {
              entitiesToSave.push(Unit);
});

var so = new breeze.SaveOptions({ allowConcurrentSaves: true })
            return manager.saveChanges(entitiesToSave,so)
                    .then(saveSucceeded)
                    .fail(saveFailed);
}

向所有人致敬。

于 2014-01-29T21:58:35.710 回答