Beginner's questions

Discussion of open issues, suggestions and bugs regarding EntityDAC
Post Reply
Posts: 3
Joined: Mon 23 Feb 2015 15:15

Beginner's questions

Post by jan.drozen » Thu 26 Feb 2015 15:28

as I stated in my recent question, I'm a new user of EntityDAC (now the Pro version) and I'm a little bit confused about some things in documentation or samples provided:

Collection and references ... tities.htm

The doc says I have to use Record<T> or Collection<T>. However I was not able to get this in order. I believe the doc is in contradiction with EntityDAC source - EntityDAC.MetaEntity lines 1824 and 1833. There is a record type expected but is restricted to TReferenceData or TCollectionData.

There are three required and two optional parameters defined for Collection attribute - and the example below has six parameters. What is right?

When using atribute mapped entities I have to override both constructors and (it may be optional) the Register method. In the Register method I have to register references and collections using RegisterReference or RegisterCollection. Where can I find documentation for this methods? When I'm using RegisterReference I have to get some metadata from the MetaReferences list. What do I need to get for the RegisterReference? For me is the reference field name without the leading character cut working. But I'm not sure why it is working. What is the pattern for get the RegisterReference working properly?

These are some of things that were some kind of obstacles of a newbie.
I'm sure answering it helps me and all other new users.

Best regards,

Devart Team
Posts: 235
Joined: Thu 05 Apr 2012 07:32

Re: Beginner's questions

Post by ZEuS » Fri 27 Feb 2015 11:40

Thank you for the information. We are constantly working to improve the documentation and will complement this article in one of the next EntityDAC builds.
In the matter of this situation. There is a little difference between attribute mapping of trivial classes (TObject descendants) as it is described in the help article and mapping of TMappedEntity descendants as you trying to do it.
For a TObject descendant, a reference must have the Reference<T> type, and no further actions are required. For a TMappingEntity descendant, a reference must have the TReferenceData type, and you have to register it in the Register method in the following manner:

Code: Select all

RegisterReference(FDept, MetaType.MetaReferences.Get('Dept'));
- FDept is a TEmp class field of the TReferenceData type that represents the reference to TDept;
- 'Dept' is the name of a referenced meta-type. The name is the referenced class name (TDept) without a leading 'T'.

Post Reply