Why Does Linq Generated Sql Include Multiple "is Null" Conditions For The Same Column
The following query against a SQL Server 2012 database, using Entity Framework Core 3.1: var tows = await _context.DataEntryTow .Where(t => _context.DataEntr
Solution 1:
Field MicroscopeId
declared as nullable. So, to mimic LINQ to Objects behaviour when null != "0"
is true
but in SQL null <> '0'
is false, EF Core generates additional OR
condition.
To disable this geneeration you have to specify that when building DbContextOptions:
optionsBuilder.UseSqlServer(constr, b => b.UseRelationalNulls(true) );
Additional info: https://docs.microsoft.com/en-us/ef/core/querying/null-comparisons#using-relational-null-semantics
Post a Comment for "Why Does Linq Generated Sql Include Multiple "is Null" Conditions For The Same Column"