如何获取内存中对象的数据集?

2024-03-28

有谁知道与泛型和 RTTI 一起使用的 TDataset 后代,以便我可以编写这样的代码,并在 GUI 中使用数据感知组件? :

...
ds:TDataset<TPerson>;
...

procedure DoStuff;
begin    
  ds:=TDataset<TPerson>.create;
  ds.add(TPerson.Create('A.','Hitler',77));
  ds.add(TPerson.Create('O.','Bin Laden',88));
 end; 

This should有可能。可以通过 RTTI 创建 fielddef,因为数据的确切类型是已知的。值还可以自动来回整理,因此您可以查看和编辑类或记录中的数据。

我讨厌编写大量无用的编组代码,而所需的信息已经可以通过 RTTI 获得。

或者也许有人曾经编写过某种 TEnumerable TDataset 适配器?

是否存在类似的东西,或者我应该开始写一个?

...

The closest thing that I could find is an (excellent!) example http://etutorials.org/Programming/mastering+delphi+7/Part+III+Delphi+Database-Oriented+Architectures/Chapter+17+Writing+Database+Components/A+Dataset+of+Objects/ by Marco Cantu, from Mastering Delphi 7, but the code itself doesn't make use of new language features like generics, the new RTTI system, or attributes, and it doesn't work with Unicode delphi. TDataset has changed since D7 too.


TAureliusDataSet 包含在TMS奥勒留 http://www.tmssoftware.com/site/aurelius.asp非常接近这一点。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何获取内存中对象的数据集? 的相关文章

随机推荐