Hi Wagner,
I want to use inheritance but with different names for the properties in the descendants that map to a common field but it is giving me problems. Basically I want to do something like this:
[Entity]
[Table('ANIMALS')]
[Sequence('GEN_ANIMAL_ID')]
[Inheritance(TInheritanceStrategy.SingleTable)]
[DiscriminatorColumn('DISCRIMINATOR', TDiscriminatorType.dtString)]
[Id('FID', TIdGenerator.IdentityOrSequence)]
TVehicleBase = class
private
[Column('ID', [TColumnProp.Required])]
FID: integer;
[Column('REG', [], 32)]
FReg: Nullable<string>;
public
property Id: integer read FID write FID;
end;
[Entity]
[DiscriminatorValue('CAT')]
TTrailer = class(TVehicleBase)
private
//
public
property CatLicense: Nullable<string> read FReg write FReg;
end;
[Entity]
[DiscriminatorValue('DOG')]
TTrailer = class(TVehicleBase)
private
//
public
property DogLicense: Nullable<string> read FReg write FReg;
end;
If I do this I get the error "property not found on class" when I try to use it in an Aurelius Dataset. It will work if move the private field and the attribute to the descendants as follows:
[Entity]
[Table('ANIMALS')]
[Sequence('GEN_ANIMAL_ID')]
[Inheritance(TInheritanceStrategy.SingleTable)]
[DiscriminatorColumn('DISCRIMINATOR', TDiscriminatorType.dtString)]
[Id('FID', TIdGenerator.IdentityOrSequence)]
TVehicleBase = class
private
[Column('ID', [TColumnProp.Required])]
FID: integer;
public
property Id: integer read FID write FID;
end;
[Entity]
[DiscriminatorValue('CAT')]
TTrailer = class(TVehicleBase)
private
[Column('REG', [], 32)]
FCatLicense: Nullable<string>;
public
property CatLicense: Nullable<string> read FCatLicense write FCatLicense;
end;
[Entity]
[DiscriminatorValue('DOG')]
TTrailer = class(TVehicleBase)
private
[Column('REG', [], 32)]
FDogLicense: Nullable<string>;
public
property DogLicense: Nullable<string> read FDogLicense write FDogLicense;
end;
But this will mean that if I try to build the database using Aurelius it will try and create a table with two DOG fields!
I've tried various different ways of doing it never seems to work properly. I guess it's just not possible to have this without issues but I thought I'd just check with you first before I give up and go to plan B. Any ideas?
Regards
Steve