我认为当您将子实体添加到另一个实体然后将子实体标记为已删除(之前未保存更改)时,我发现了一个错误。
这是测试:
test("delete unsaved entity", 1, function () {
var realEm = newEm();
//ok(realEm.hasChanges() === false, "The entity manager must not have changes");
var query = EntityQuery.from("Customers")
.where("CustomerID", "==", "729de505-ea6d-4cdf-89f6-0360ad37bde7")
.expand("Orders");
stop();
realEm.executeQuery(query)
.then(function (data) {
var cust = ko.observable(data.results[0]);
var newOrder = realEm.createEntity("Order", {}, breeze.EntityState.Detached);
cust().Orders.push(newOrder);
//ok(newOrder.entityAspect.entityState.isAdded() === true, "The entity is Added");
newOrder.entityAspect.setDeleted();
//ok(realEm.hasChanges() === true, "The entity manager must have changes? Not clear to me but it's true");
realEm.saveChanges();
ok(realEm.hasChanges() === false, "The entity manager must not have changes");
})
.fin(start);
});