-1

我有一个表 TaxReturn,它有一个 ProcessID 的主外键,它映射到 ProcessID 的流程表主键。我需要将 TaxReturn 的 ProcessID 设置为 Process 表的 ProcessID。如何使用 Breeze 执行此操作,这样我就不会保存两次并两次往返数据库?

4

1 回答 1

0

May I rephrase?

  • You have two tables, Process and TaxReturn
  • Process has a 1..(0,1) association with TaxReturn
  • ProcessID is the PK of Process
  • ProcessID is the PK of TaxReturn and is also the FK to the parent Process

Thus a Process can have zero or one TaxReturns.

If you create and save aProcess and TaxReturn at the same time (assuming the camelCase NamingConvention):

var process = manager.createEntity('Process');
var taxReturn = manager.createEntity('TaxReturn', {ProcessID: process.processID});
// ... fill them in
return manager.saveChanges(); // Breeze saves them together in a single transaction.

If you add a TaxReturn to an existing Process:

var taxReturn = manager.createEntity('TaxReturn', {ProcessID: existingProcess.processID});
// ... fill them in
return manager.saveChanges(); // saves the new TaxReturn.
于 2013-03-18T22:29:41.573 回答