我有一个表 TaxReturn,它有一个 ProcessID 的主外键,它映射到 ProcessID 的流程表主键。我需要将 TaxReturn 的 ProcessID 设置为 Process 表的 ProcessID。如何使用 Breeze 执行此操作,这样我就不会保存两次并两次往返数据库?
问问题
140 次
1 回答
0
May I rephrase?
- You have two tables,
Process
andTaxReturn
Process
has a 1..(0,1) association withTaxReturn
ProcessID
is the PK ofProcess
ProcessID
is the PK ofTaxReturn
and is also the FK to the parentProcess
Thus a Process
can have zero or one TaxReturn
s.
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 回答