Delphi:应用更新时访问嵌套数据集主信息
将更新应用到嵌套数据集时,我可以在提供程序的 BeforeUpdateRecord
事件中访问父数据集信息(例如 MyField.NewValue
)吗?
原因:
当我将更新应用于具有嵌套详细信息的 CDS 时,主 PK 由基础查询 (TIBCQuery
) 生成并传播到主 CDS。
但新键在详细信息的 BeforeUpdateRecord
中不可见,因为该字段在 AfterUpdateRecord
中更新:
DeltaDS.FieldByName(FieldName).NewValue := SourceDS.FieldByName(FieldName).NewValue)
并且增量尚未合并。
当调用详细信息时,BeforeUpdateRecord
事件的 DeltaDS
参数看起来仅包含嵌套数据集的信息。
如果我可以执行以下操作,那就太好了:
DeltaDS.ParentDS.FieldByName('FIELDNAME').NewValue.
编辑:
当使用嵌套数据集时,BeforeUpdateRecord
事件被调用两次,一次用于主数据,一次用于详细数据(如果我们两者都有一份记录)。当调用详细信息事件时,有没有办法访问 DeltaDS 中包含的主信息?
此时我们无法访问主 CDS 的数据,因为更改尚未合并。我希望这不会增加更多的混乱。
Can I access the parent dataset information (like MyField.NewValue
) in the BeforeUpdateRecord
event of a provider when applying the updates to the nested dataset?
Reason:
When I apply updates to a CDS that has a nested detail, the master PK is generated by the underlying query (TIBCQuery
) and propagated to the master CDS.
But the new key is not visible in the BeforeUpdateRecord
of the detail as the field is updated in the AfterUpdateRecord
:
DeltaDS.FieldByName(FieldName).NewValue := SourceDS.FieldByName(FieldName).NewValue)
and the delta is not merged yet.
It looks like the DeltaDS
parameter of the BeforeUpdateRecord
event contains only information to the nested dataset when the call occurs for the details.
It would be nice if I could do something like:
DeltaDS.ParentDS.FieldByName('FIELDNAME').NewValue.
Edit:
When using nested datasets the BeforeUpdateRecord
event is called twice, once for the master and once for the detail (if we have one record of both). When the event is called for the detail, is there a way to access the master information contained in the DeltaDS
?
We can't access the data of the master CDS at that moment as the changes are not already merged. I hope this is not adding more confusion.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用提供程序的
Resolver
查找相应的TUpdateTree
:您可以在
OnBeforeUpdate
处理程序中使用它:You can use the provider's
Resolver
to look up the correspondingTUpdateTree
:You can use this in your
OnBeforeUpdate
handler: