views:

35

answers:

1

Hello,

I know this query is working as left join. But more importantly i want to know why is it working as Left Join? How does the query execution flows?

 var query = from cust in objNorthwindEntities.Customers
                        join orders in objNorthwindEntities.Orders on cust equals orders.Customer
                        into groupedCust
                        select new
                        {
                            custName = cust.ContactName,
                            orders = groupedCust
                        };

The query contains cust equals orders.Customer, then how does it work as left join.

Thanks in advance :)

+3  A: 

why is it working as Left Join?

The use of the into keyword in the join clause makes it a group join:

From MSDN

If no elements from the right source sequence are found to match an element in the left source, the join clause will produce an empty array for that item.

So it looks like it's working as a left join, but it's actually a group join, which is a Linq specific feature that has no direct relational equivalent.

Thomas Levesque