question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Two different ways of writing the query conditions, the translation statements are inconsistent

See original GitHub issue

Two 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:closed
  • Created 4 years ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
REscobarcommented, Oct 13, 2019

If IsDeleted is nullable, the expected behaviour is those two different queries

0reactions
ajcvickerscommented, Oct 18, 2019

We 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found