Query: Errorneous IS NULL check in SQL causing repetitive null checks or invalid SQL with coalesce #7784
Labels
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
type-bug
Milestone
It looks like the SQL generated from a null-coalesce operator changes depending on a previous statement in the Linq expression. So far I've only noticed this change in behavior when a Where statement contains a !StartsWith somewhere in the Linq expression (doesn't matter if it's before or after).
The problem is that after doing the null-coalesce, it tacks on
[employee].[DirectorId] IS NOT NULL
, which is unexpected.Actual SQL
Expected SQL
Steps to reproduce
I've provided the DDL and the following code that demonstrates a few different examples of StartsWith, !StartsWith, and different coalesce statements.
FirstName does start with "Test" and null-coalesce operator to coalesce DirectorId/Id
FirstName does start with "Test" and null-coalesce operator to coalesce DirectorId/Id
FirstName does not start with "Test" and null-coalesce operator to coalesce DirectorId/Id
FirstName does not start with "Test" and ternary operator to coalesce DirectorId/Id
Further technical details
EF Core version: 1.1.0
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: Windows 7
IDE: Visual Studio 2017, Project Rider EAP 1.0
The text was updated successfully, but these errors were encountered: