Does anyone know of a TDataset descendant that works with Generics and RTTI so that I can write such code and use data-oriented components in a graphical interface?
... 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;
It should be possible. Field identifiers can be created via RTTI because the exact data type is known. Values ββcan also be automatically sorted back and forth, so you can view and edit data in a class or record.
I do not like to write a lot of useless marshalling code, while the necessary information for this is available through RTTI already.
Or maybe someone once wrote some TEnumerable β TDataset adapter?
Is there something similar, or should I start writing?
...
<sub> The closest I could find is an (excellent!) example from Marco Cantu, from Mastering Delphi 7, but the code itself does not use new language functions like generic tools, the new RTTI system or attributes, and it does not work with delici unicode. TDataset has changed from D7 too.
Sub>
generics rtti delphi tdataset
Wouter van nifterick
source share