Two different ways of writing the query conditions, the translation statements are inconsistent
See original GitHub issueTwo different ways of writing the query conditions, the translation statements are inconsistent
Steps to reproduce
var a = dbContext.Test.Where(a => !a.IsDeleted).FirstOrDefault();
SELECT TOP(1) [b].[IsDeleted]
FROM [Test] AS [b]
WHERE ([b].[IsDeleted] <> CAST(1 AS bit))
var b = dbContext.Test.Where(a => a.IsDeleted == false).FirstOrDefault();
SELECT TOP(1) [b].[IsDeleted]
FROM [Test] AS [b]
WHERE ([b].[IsDeleted] = CAST(0 AS bit))
Expected behavior
The translation statement is consistent and uses the second
Further technical details
EF Core version:3.0.0 Database provider: Microsoft.EntityFrameworkCore.SqlServer Target framework: NET Core 3.0 Operating system:Win10 IDE: Visual Studio 2019 16.3
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (8 by maintainers)
Top Results From Across the Web
Chapter 4. Query Performance Optimization
In the previous chapter, we explained how to optimize a schema, which is one of the necessary conditions for high performance. But working...
Read more >Inconsistency between ifelse and case_when using dbplyr
The issue appears to be the SQL syntax that the two commands ifelse and case_when get translated into. The case_when syntax does not...
Read more >sql - Contradictory condition checks on Where with a Case ...
ELSE in this stored-procedure with two different queries. That's more verbose but also more efficient. Share. Share a link to this answer.
Read more >SQL Queries - OutSystems 11 Documentation
SQL in OutSystems queries always have two output parameters, even when the query executed doesn't return a result:.
Read more >10. Analyzing the Meaning of Sentences
We started out trying to capture the meaning of (1a) by translating it into a query in another language, SQL, which the computer...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
If
IsDeleted
is nullable, the expected behaviour is those two different queriesWe discussed this in triage and the general feeling is that, other than for correctness, we should translate what was written as closely as possible, especially where doing otherwise will perform differently on different back ends. However, we could revisit this if we find many people falling into a performance trap because of this.