Reuse table join added during Where processing for Fetch clause

Description

SQL Server 2012, .NET 4.5

Having many-to-one one way relation say [principal *- consumer] and linq query like:

session.Query<Principal>().Where(principal => principal.Consumer.Name == "John").Fetch(principal => principal.Consumer)

I result in following sql:

select
principal0_.Id as Id2_0_,
consumer1_.Id as Id1_1_,
principal0_.Consumer_Id as Consumer2_2_0_,
consumer1_.Name as Name1_1_
from
Principal principal0_
left outer join
[Consumer] consumer1_
on principal0_.Consumer_Id=consumer1_.Id
inner join
[Consumer] consumer2_
on principal0_.Consumer_Id=consumer2_.Id
where
consumer2_.Name=@p0;
@p0 = 'John' [Type: String (4000)]

And it's obvious that left outer join can be thrown away.

As I managed to understand logic responsible for this behavior is located somewhere in DotNode class of AST component.

Environment

None

Activity

Alex Zaytsev 
July 16, 2013 at 8:57 AM

, sorry last coment - my mistake here.

Closed as duplicate of

Maksim Kim 
July 16, 2013 at 8:52 AM

Can you explain please?

Duplicate

Details

Assignee

Reporter

Labels

Components

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created July 16, 2013 at 8:22 AM
Updated July 16, 2013 at 8:57 AM
Resolved July 16, 2013 at 8:56 AM
Who's Looking?