projections on Multiple tables (inheritance)

Hi,
  I need to translate SQL below to aurelius.

SELECT P1.Name, P2.Birthday, P3.Status
FROM Person3 P3
LEFT JOIN Person2 P2 ON P2.Id=P1.Id
LEFT JOIN Person3 P3 ON P3.Id=P1.Id
WHERE P3.Status=True;

NOTES:
  I don't need "aLotOfFields" from P1, P2, P3.
  I'm trying to use projections, there are another way?
 
 
 TPerson1 = class
 private
    FId: Int64;
    FName: string;
    aLotOfFields: ....
 end;

 TPerson2 = class (TPerson1)
 private
    FId: Int64;
    FBirthday: TDateTime;
    aLotOfFields: ....
 end;

 TPerson3 = class (TPerson2)
 private
    FId: Int64;
    FStatus: Boolean;
    aLotOfFields: ....
 end;

Thanks

Projections are the way to go. What did you try and what did not work, exactly?

Hi,
  Sorry but i just don't know where to start. Is there a sample on the documentation?

  Results := Manager.Find<TPersone3>
                              .CreateAlias('Id', 'P1')  //???
                              .Select(TProjections.ProjectionList
                                     .Add(TProjections.Prop('Id')) //???
                                     )
                              .ListValues;
 
 raised exception class EPropertyNotFound with message 'Property "Id" not found on class "TPersone3".'.

Thanks

The Select part is correct, the CreateAlias is not needed because you don't have associations, but inheritance, according to your mapping. Please post your exact mapping here. The error happens because your FId property is maybe not mapped in TPersone3? Also, if you are inheriting TPersone3 from TPersone2 you don't need to redeclare FId in all classes. 


There is a full chapter about projections in Aurelius manual, it's really extensive: http://www.tmssoftware.biz/business/aurelius/doc/web/projections.html

Hi, Wagner
  "Also, if you are inheriting TPersone3 from TPersone2
you don't need to redeclare FId in all classes...", true, sample code is
wrong, but my true code is OK.

  "...the CreateAlias is not needed because you don't have associations...", this is the real mistake

Works like a charm, thanks