Nhibernate: Is it possible to query fields on tables linked by a joint table

26 views
Skip to first unread message

cxg cxg

unread,
Oct 31, 2019, 1:48:03 PM10/31/19
to nhusers
I have two tables which are linked by a joint table:

Staff (one) <-- (many) StaffRights 

StaffRights (many) --> (One) Rights

    Table1 --> Staff
    StaffID: PK
    Name

    Table2 --> StaffRights
    SRID: PK
    StaffID:FK
    RightID:FK
    CreatedTS

    Table3 -->Rights
    RightID: PK
    RightName

And I want to select columns from all the tables doing something like this:


    Select s.Name, s.StaffID, sr.RightID, r.RightSelectName 
    From Staff s 
    INNER JOIN StaffRights sr ON s.StaffID = sr.StaffID 
    INNER JOIN Rights r ON sr.RightID = r.RightID 
    Where sr.DeletedTS IS NULL AND s.DeletedTS IS NULL AND s.IsSelfservice = 0 s.Name = 
    'myquery1' AND s.Pwd = 'myquery2'

This link claim that it can only be done via HDL [http://www.independent-software.com/nhibernate-fast-loading-of-data-from-multiple-tables-into-a-tree-structure.html][1] Can't I do via query api, I have tried joinalias, Inner.JoinQueryOver, none of them work so far.


Reply all
Reply to author
Forward
0 new messages