This question is locked. New answers and comments are not allowed.
Using OA latest (2015.1.225)
Using the Northwind sample database (model generated without any alterations)
The following query:
generates the following SQL:
However since the ReportsTo column (corresponding to the Employee1 navigation property) is nullable the second join should either be LEFT JOIN or the following query should be generated:
As a temporary workaround I can write an explicit exists clause:
or possibly
This bug might be related to http://www.telerik.com/forums/invalid-sql-generated-with-navigation-properties-and-defaultifempty
Using the Northwind sample database (model generated without any alterations)
The following query:
from c in db.Categoriesjoin e in db.Employees on c.CategoryID equals e.EmployeeIDwhere e.Employee1.FirstName == "Andrew"select e;generates the following SQL:
SELECT ...FROM [Categories] aJOIN [Employees] AS b ON (a.[CategoryID] = b.[EmployeeID])JOIN [Employees] AS c ON (b.[ReportsTo] = c.[EmployeeID])WHERE (c.[FirstName] = 'Andrew') However since the ReportsTo column (corresponding to the Employee1 navigation property) is nullable the second join should either be LEFT JOIN or the following query should be generated:
SELECT ...FROM [Categories] aJOIN [Employees] AS b ON (a.[CategoryID] = b.[EmployeeID])WHERE EXISTS( SELECT 1234567 FROM [Employees] c WHERE b.[ReportsTo] = c.[EmployeeID] AND c.[FirstName] = 'Andrew')As a temporary workaround I can write an explicit exists clause:
from c in db.Categoriesjoin e in db.Employees on c.CategoryID equals e.EmployeeIDwhere db.Employees.Any(e2 => e2 == e.Employee1 && e2.FirstName == "Andrew")select e;or possibly
var q0 = db.Employees.Where(e => e.FirstName == "Andrew");from c in db.Categoriesjoin e in db.Employees on c.CategoryID equals e.EmployeeIDwhere q0.Contains(e.Employee1)select e;This bug might be related to http://www.telerik.com/forums/invalid-sql-generated-with-navigation-properties-and-defaultifempty