Invalid SQL when Ordering by comparison with null
Posted: Mon 15 Jun 2020 08:01
I want to Order my collection by comparing a value to null. That way I can force nulls to appear first or last for specific query. The problem is that Devart.Data.Oracle.EFCore (version 9.11.980) generates invalid SQL query.
Example LINQ query:
Generated SQL (not valid):
I would expect it to generate something like:
I think the context I have provided should be enough but let me know if you need any additional details.
Example LINQ query:
Code: Select all
context.Entities
.OrderBy(x => x.SomeString != null)
.ThenBy(x => x.SomeString)
.ToList()
Code: Select all
SELECT "v".SOME_STRING
FROM ENTITY "v"
ORDER BY "v".SOME_STRING IS NOT NULL, "v".SOME_STRING
Code: Select all
SELECT "v".SOME_STRING
FROM ENTITY "v"
ORDER BY CASE WHEN "v".SOME_STRING IS NOT NULL THEN 1 ELSE 0 END, "v".SOME_STRING
I think the context I have provided should be enough but let me know if you need any additional details.