Make discriminator value readable

It would be helpful, if the DiscriminatorColumn could be used as a readable property within an Entity-Instance.

Right now, I'm not able to use SingleTable Inheritance, if the DiscriminatorValue has to be shown within a Dataset.

see How to map a discriminator value to a property ?

a Possible solution could be setting something like MappedBy in Associations for the DiscriminatorColumn attribute.

For Example:

[Entity]
[DiscriminatorColumn('Type', TDiscriminatorType.dtString, 'FType')]
TFiles = class
private
  FType: string;
...
end;

or it would be more easy to do in that way (but I think it is harder to implement):

[Entity]
TFiles = class
private
  [DiscriminatorColumn('Type')]
  FType: string;
...
end;

This could be achieved without any implementation by creating a public property in the base class with a virtual getter, and implement the getter returning a fixed value for each class in the hierarchy:

TFiles = class
protected
  function GetType: string; virtual;
public
  property &Type: string read GetType;

TMyDescendant = class(TFiles)
protected
  function GetType: string; override;

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