Is there a way for Entity Framework to respect the "UseDatabaseNullSemantics" option in a left join?
Basically, I'd like to prevent the addition of "OR (([ExtentX].[Property] IS NULL) AND ([ExtentY].[Property] Is Null))" that gets added to the generated SQL query. I've seen the following discussions, but none of them provide a solution that will work for my query:
UseDatabaseNullSemantics still generating NULL checks
Why is EF generating SQL queries with unnecessary null-checks?
Prevent NULL checks in LINQ to Entity Joins
It has to be a Left Join... I cannot put the join condition in a where clause because it does not produce the same results, and I need to allow null data if there are no matches (hence the left join).
Basically, I have a query similar to:
(from c in dbContext.CPUs
join u in dbContext.UData on c.User equals u.User into ud
from uds in ud.DefaultIfEmpty()
select new ResultOjbect{});
And it generates this nasty SQL:
SELECT BLAH FROM CpuTable LEFT OUTER JOIN UserTable (ON CPUTable.User = UserTable.User)
OR ((CpuTable.User IS NULL) AND (UserTable.User IS NULL))
The addition of OR ((CpuTable.User IS NULL) AND (UserTable.User IS NULL)) causes horrible performance and makes the query take 2 minutes for 17000 records. If you remove this from the generated SQL, it takes 23 seconds to load 17000+ records.
Why is there no option to control this? This is incredibly unnecessary and slows my query to a crawl. Anyone know a work-around?