Using Delphi record inside the class for the data

In a project I have many http requests running in separate threads that return query data in xml from a service out of my control. Till now I use an xml parser to transform them to Delphi record types.
I was thinking to use aurelius to have the possibility to use more than one type of databases and have them also in a mobile app for tablets.
Aurelius uses and manipulates class objects and I was wondering a class like the following can be used and how can be used:
Type Dtest=record
type Ttest=class
property id:integer read write;
property name:string read Ftest.nam write Ftest.nam;
Should I put the attributes for Aurelius in proprties section? Is there an other solution?
In this example we have 2 properties but the usual is to have 10 to 50 in my records and to copy a record is much faster than each variable separate in creation/copy of the class for aurelius and usually I use arrays of records.
Thank you in advance

Unfortunatly XData do not support Record's serialization. I have a feature request for that: 2460: Add support for Record types

You can vote for it if find usefull.

1 Like

You may use any kind of Filed / Property datatypes, since they're not auto-or-manually mapped with Aurelius attributes (if you're automapping, declare [Transient] to your customized-class/record fields). You may manipuate them through any methods, or properties' read/write declarations.
Aurelius persistency will take care just of the persistency-mapped fields.
You should declare any needed properties to use, and make methods to wrap/unwrap it's content after/before Aurelius read/write operations. Maybe into manage Blob fields or other mapped fields with supported datatypes.


MyEntity := myobjmanager.Find<TestEntity>(1);
MyEntity.UnWrapXMLContent; // will take the content from a persisted field, and expand to your customized field
MyEntity.Test.Nam := 'NewName';
MyEntity.WrapXMLContent; // will take the content from your customized field and wrap to an Aurelius mapped persistent field
1 Like

If working with Aurelius entities, by default XData will try to serialize your Fields unless you tell not to using [XDataExcludeProperty] attribute.The same way you have to use [XDataProperty] attibute to any property you want serialized. Ex:

  TSomeAureliusEntity = class
     FId: Integer;
     FName: string;
    procedure SetName(const AName: string);
    property Id: Integer read FId write FId;
    property Name: string read FName write SetName;

This way (de)serialization with work on FId field and Name property.


1 Like

I voted. I usually prefer not to use automapping to be sure.

1 Like

The same way I thought I should use.
A question I have is what Aurelius will use and keep outside the class object that can be changed by the wrap procedures. But I believe Aurelius has not a mechanism to be informed on-line by the content change. It is just "sleeping" between Find and Flush.

The unwrapped content will be held by Aurelius field/properties that are already mapped to database and tracked by Aurelius.