Aurelius Query question

Part of my entitymodel contains this:


tblA --> linkAB <-- tblB --> linkBC <--tblC

I need to create a list containing the properties tblC.P1, tblB.P2 and tblA.P3

I first create a queryX that delivers the necessary linkBC entries that I need. This works.
I thought I could then build a second queryY that would use that output as a way to retrieve the tblA.P3. But I can not seem to get this working. 


QueryX:
  CategoryPages := aObjManager.Find<TlinkCategoryPage>
                     .CreateAlias('fPage', 'fp')
                     .CreateAlias('fCategory', 'fc')
                     .Add(TExpression.Like( 'fp.PageType', 'Q%' ))
                     .OrderBy('fc.ftext')
                     .List;
 
  TlinkCategoryPage has the property Page of TCustomPage.

Query Y:
   GroupPage := aObjManager.Find<TlinkGroupPage>
                           .Add(TExpression.Eq( TProjections.Prop('fPage'), CategoryPages.Page ))
                           .List;

  TlinkGroupPage also has the property Page of TCustomPage.

I seem unable to use TlinkCategoryPage.Page in an expression.

Questions:
a) Is there a way to use objects in an expression ?
b) I might be on the wrong track with this approach: any other approach you would suggest?

Thanx in advance!




 

If you want to filter by a single page, you could use Page.Id to find the object:


GroupPage := aObjManager.Find<TlinkGroupPage>
                          .CreateAlias('fPage', 'p')
                           .Add(TExpression.Eq( TProjections.Prop('p.Id'), CategoryPages.Page.Id ))
                           .List;

but I suppose you want to link both queries? In this case you should create a ManyValueAssociation in TCustomPage named "GroupPages", for example. Then you can link it this way:

CategoryPages := aObjManager.Find<TlinkCategoryPage>
                     .CreateAlias('fPage', 'fp')
                     .CreateAlias('fCategory', 'fc')
                     .CreateAlias('fp.GroupPages', 'gp')
                     .Add(TExpression.Like( 'fp.PageType', 'Q%' ))
                     .OrderBy('fc.ftext')
                     .List;

from that you can use projections to bring properties from Page (fp), Category (fc) and GroupPages (gp)

Your suggestion for TProjections.Prop('p'Id') did the trick. Thanx Wagner!