Null Coalesce Operator between two join variable - throws exceptions #27386
Labels
area-query
customer-reported
punted-for-7.0
Originally planned for the EF Core 7.0 (EF7) release, but moved out due to resource constraints.
type-bug
Milestone
Ok, as a sample (Code 1#) I just share part of my code to see how the issue has happened, and why we may need it?
In the following query (Code 1#) as you can see, I used the
let
operator, which first I thought, hey the issue is for usinglet
as it was previously reported to cause an issue... but later, after inline-ing (Code 2#) the result of thelet
operator, I noticed the issue is still persistsAs you can see I have two join, and I use let to decrease complexity, duplicate null checking and improve the readability of code.
But both codes failed, and unfortunately as we are near the deadline, I'm afraid I cannot provide you stack trace; but the error was not reporting anything meaningful, and the query worked before I start to filter data, so my suggestion is at some point when it fails to bring data, the
(x??y).Data
will face null reference exception of some kind, but EF handlesx.Data ?? y.Data
just fine as the last query succeed (Code 3#) and as we do not have the Null Propagation operator (?,
) in LINQ queries either it is a bug, or same toDefaultIfEmpty()
it just needs a replacement, or the best solution is that Null Coalesce operator (??
) work as expected even in such cases.let
The text was updated successfully, but these errors were encountered: