R – NHibernate Query problem

nhibernate

I'm quite new to NHibernate and starting to find my way around.

I have a domain model that is somewhat like a tree.

Funds have Periods have Selections have Audits
Now I would like to get all Audits for a specific Fund

Would look like this if I made it in SQL

SELECT A.*
FROM Audit A
JOIN Selection S ON A.fkSelectionID = S.pkID
JOIN Period P ON S.fkPeriodID = P.pkID
JOIN Fund F ON P.fkFundID = F.pkID
WHERE F.pkID = 1

All input appreciated!

Best Answer

Try this

select elements(s.Audits)
from Fund as f inner join Period as p inner join Selection as s  
where f = myFundInstance  
Related Topic