I have a pretty simple one to many mapping using Fluent NHibernate and it works fine except the the queries NH generates are less than ideal. I found this when I checked the sql log from NH.
The query I am looking for is like
select p.*, c.* from parent p inner join child c on p.Id = c.parentId
where p.ID is the PK of the parent table and c.ParentId is a FK in the child table pointing to the PK of the parent table.
But what I found from the sql log is something like this:
select P.* from Parent
followed by a bunch of queries running against the child table like
select * from child c where c.ParentId = @p0
Not surprisingly this is causing performance issues.
My question is why NH is not generate the inner join query I think it should? What do I need to change so that NH will generate the desired query?