c# - LINQ to SQL, multiple table join, generated SQL missing 2nd INNER JOIN -


can tell me why generated sql not contain 2nd inner join? seems have been replaced null check in clause? i'm not clear on why 2nd inner join not in generated sql.

c# code:

var cyclelist = o in entities.orders               join c in entities.cycles on o.id equals c.orderid               join calendar in entities.calendars on c.calendarid equals calendar.id             o.unitid == unitid && o.companyid == companyid             select c.id; 

generated sql:

select  [extent2].[id] [id]  [dbo].[orders] [extent1]     inner join [dbo].[cycles] [extent2] on [extent1].[id] = [extent2].[orderid] ([extent2].[calendarid] not null) , ( cast( [extent1].[unitid] int) = @p__linq__0) , ( cast( [extent1].[companyid] int) = @p__linq__1) 

it looks query generator optimizing query.

since not selecting (or using in clause) fields calendars table in query, 1 join done between orders table , cycles table. it's faster check non-null foreign key join on table no fields used.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -