可以在 delphi 数据集中创建假数据字段吗? [英] it's possible to create a fake data field in a delphi dataset?

查看:19
本文介绍了可以在 delphi 数据集中创建假数据字段吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 DataSet(不是 ClientDataSet)中创建一个假"数据字段:

I want to create a 'fake' data field in a DataSet (not ClientDataSet):

  • 该字段不应存储在数据库中
  • 这不是一个计算字段(应该允许用户输入输入数据)
  • 该字段具有业务逻辑意义,因此用户更新其值后应更新其他字段(使用 OnFieldChange 事件)

我知道我可以有一个简单的无 dbaware 控件,捕获它的 OnChange 事件并在那里执行计算(或调用 DataModule 函数,DataSet 所在的位置)但我认为如果我可以重新利用数据集自动绑定它会更干净带有 db-ware 控件和数据集事件..

I know I can have a simple no-dbaware control, capture it's OnChange event and perform the calculations there (or call a DataModule function, where the DataSet resides) but I think it's more clean if I can reutilize the dataset automatic binding with db-ware controls and dataset events..

同样,Form(Presentation)和 DataModule(Model)之间的独特连接是 DataSet(耦合较少)..

Also this way the unique connection between the Form (Presentation) and the DataModule (Model) it's the DataSet (less coupling)..

PD:我正在使用 fibplus,我认为解决方案(如果有的话)将在 VCL 级别..

PD: I'm using fibplus, with I think the solution (if any) will be at the VCL level..

谢谢!

推荐答案

您是否尝试过使用 InternalCalc 字段?您的数据感知控件将允许您编辑 InternalCalc 字段的值,并且该值存储在数据集中.

Have you tried using an InternalCalc field? Your data aware controls will let you edit an InternalCalc field's value, and the value is stored in the dataset.

如果您在设计时在数据集(TClientDataSet、TQuery 等)中创建一个 InternalCalc 字段,它几乎就是您所要求的.

If you create an InternalCalc field in the dataset (TClientDataSet, TQuery, etc.) at design time, it's almost exactly what you're asking for.

这篇关于可以在 delphi 数据集中创建假数据字段吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆