What Is this the right way of using ThenFetch() to load multiple collections?

14 views
Skip to first unread message

Daniele

unread,
Oct 29, 2010, 6:28:38 AM10/29/10
to nhusers
I'm trying to execute a query like this with NH 3.0 Beta 1

NhQueryable<CandidateGroup> nh = new
NhQueryable<CandidateGroup>(session);
nh.Fetch(p => p.RevisioneGruppo).ThenFetch(p => p.Gruppo)
.Fetch(p => p.RevisioneGruppo).ThenFetch(p => p.Particolari)


but the sql query ( on MYSQL ) that i obtain is this

select *
from tdm_candidate_group candidateg0_
left outer join Tdm_Revisione_Gruppo revisioneg1_ on
candidateg0_.TDM_REVISIONE_GRUPPO_ID=revisioneg1_.Id
left outer join Tdm_Gruppo gruppo2_ on
revisioneg1_.TDM_GRUPPO_ID=gruppo2_.Id

left outer join Tdm_Revisione_Gruppo revisioneg3_ on
candidateg0_.TDM_REVISIONE_GRUPPO_ID=revisioneg3_.Id
left outer join Tdm_Particolare_Utilizzo particolar4_ on
revisioneg3_.Id=particolar4_.TDM_REVISIONE_GRUPPO_ID

how i can obtain the right query that is

select *
from tdm_candidate_group candidateg0_
left outer join Tdm_Revisione_Gruppo revisioneg1_ on
candidateg0_.TDM_REVISIONE_GRUPPO_ID=revisioneg1_.Id
left outer join Tdm_Gruppo gruppo2_ on
revisioneg1_.TDM_GRUPPO_ID=gruppo2_.Id
left outer join Tdm_Particolare_Utilizzo particolar4_ on
revisioneg1_.Id=particolar4_.TDM_REVISIONE_GRUPPO_ID

P.S
Sorry for my englush

Reply all
Reply to author
Forward
0 new messages