Hi Ivan,
Can you post this to the NH-Users group?
http://groups.google.com/group/nhusers
This group is for development 'of' NH not development 'with' NH.
Of note, I suspect you shouldn't attempt to do that query because I think
you'll end up with a cartesian-product in your output (I could be mistaken
though).
Cheers,
Richard
On 1 March 2012 14:39, Ivan Korytin <[email protected]> wrote:
> I have this table structure:
>
> ReferralSource - main table
> -Phone - join table Rs as one-to-one
> - Carrier - child table for Phone
> - Type - child table for Phone
> I want to get it by Linq query:
>
> Session.Query<ReferralSource>()
> .Fetch(x => x.Phone)
> .ThenFetch(x => x.Type)
> .Fetch(x => x.Phone)
> .ThenFetch(x => x.Carrier);
> And this query get this SQL code:
>
> select referralso0_.Id,
> referralso0_.FirstName,
> phonetype4_.TypeName
> carrier6_.Name
> from REFERRALSOURCES referralso0_
> left outer join PHONES phone3_
> on referralso0_.PhoneId = phone3_.Id
> left outer join PHONETYPES phonetype4_
> on phone3_.TypeId = phonetype4_.Id
> - duplicated join started
> left outer join PHONES phone5_
> on referralso0_.PhoneId = phone5_.Id
> left outer join CARRIERS carrier6_
> on phone5_.CarrierId = carrier6_.Id - duplicated join
> finished
> How can I remove duplicated left join using fetch?
>