How do I tell AureliusDataset the Classtype

Hello Wagner,

I have a global function that loads data via XData.
I want to be able to pass different classes (TCustomer, TInvoice, ...)
But AureliusDataset only creates the fields for me when I call the function via xDataClient.List( Query) and not xDataClient.List( MyClass, Query)

function TdmSngModel.TGridAdapterControl.Load(AClass: TClass; AQueryString: String): TDataset;
  QB: IXDataQueryBuilder;
  LProp: TRttiProperty;
  tempList: TList<TObject>;     // Only for debugging
  tempList: TList<TCustomer>;   // Only for debugging
//  Parent.AureliusDataset.SetSourceList( Parent.xClient.List( AClass, AQueryString));
//  Result := Parent.AureliusDataset;

  tempList := Parent.xClient.List( AClass, AQueryString);  // I have no fields, because Aurelius sees only TObject
  tempList := Parent.xClient.List<AClass>( AQueryString);  // This don't work. {E2531 Method '%s' requires explicit type argument(s)}
  tempList := Parent.xClient.List<TCustomer>( AQueryString);  // This would work but is specialized

  Parent.AureliusDataset.SetSourceList( tempList);
  Result := Parent.AureliusDataset;

I've seen that Aurelius only works internally with object lists.
What can I do to be able to work globally with the passed class here?
Or is it a simple "ignorance" on my part regarding Delphi to use the right call?


Hi Thomas,

The dataset indeed infers the base class from the tempList type. Since the type is TList<TObject>, not List<TCustomer>, it considers that the base class is TObject, not TCustomer and thus retrieves all fields from TObject.

Also note that the dataset can't infer the class from the real object itself because polymorphism should be supported, thus the class of the first object in the list might not be the base class.

Fortunately, this is simple to solve, after calling SetSourceList you can explicitly tell Aurelius what is the base class it should consider:

  Parent.AureliusDataset.SetSourceList( tempList);
  Parent.AureliusDataset.ObjectClass := AClass;
1 Like

Yes, so simple. It works fine.

Thank you

1 Like

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.