title: How can I get a dataset of in-memory objects?
body: <p>Does anyone know of a TDataset descendant that works with Generics and RTTI, so that I can write code like this, and make use of data-aware components in the GUI? :</p>
  
  <pre><code>...
  ds:TDataset&lt;TPerson&gt;;
  ...
  
  procedure DoStuff;
  begin    
    ds:=TDataset&lt;TPerson&gt;.create;
    ds.add(TPerson.Create('A.','Hitler',77));
    ds.add(TPerson.Create('O.','Bin Laden',88));
   end; 
  </code></pre>
  
  <p>This <em>should</em> be possible. The fielddefs can be created via RTTI because the exact type of the data is known. Values can also be automatically marshalled back and forth, so you can both view and edit data that's in a class or a record.</p>
  
  <p>I hate having to write a lot of useless marshalling code, while the required information for that is available via RTTI already.</p>
  
  <p>Or maybe somebody once wrote some sort of TEnumerable &lt;-> TDataset adapter?</p>
  
  <p>Does something like that exist, or should I start writing one?</p>
  
  <p>...</p>
  
  <p><sub>
  The closest thing that I could find is an (excellent!) <a href="http://etutorials.org/Programming/mastering+delphi+7/Part+III+Delphi+Database-Oriented+Architectures/Chapter+17+Writing+Database+Components/A+Dataset+of+Objects/">example</a> 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.<br>
  </sub></p>