Missing ORDER BY
See original GitHub issueInclude your code
[Table("Table_1")]
public partial class Table1
{
[Key]
public int Id { get; set; }
public DateTime CreateTime { get; set; }
}
public partial class TestContext : DbContext
{
public TestContext()
{
}
public TestContext(DbContextOptions<TestContext> options)
: base(options)
{
}
public virtual DbSet<Table1> Table1 { get; set; }
}
var services = new ServiceCollection();
services.AddDbContext<TestContext>();
var serviceProvider = services.BuildServiceProvider();
var testContext = serviceProvider.GetRequiredService<TestContext>();
var sql = testContext.Table1.OrderBy(a => a.Id).Distinct().ToQueryString();
Console.WriteLine(sql);
Expected Behavior
SELECT DISTINCT [t].[Id], [t].[CreateTime]
FROM [Table_1] AS [t]
ORDER BY [t].[Id]
Actual Behavior
SELECT DISTINCT [t].[Id], [t].[CreateTime]
FROM [Table_1] AS [t]
Include provider and version information
EF Core version:6.0.0-preview.7.21378.4 Database provider: Microsoft.EntityFrameworkCore.SqlServer Target framework: .NET 6.0 Operating system:Win11 IDE: Visual Studio 2022 17.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:19 (19 by maintainers)
Top Results From Across the Web
ORA-30485: missing ORDER BY expression in the window ...
This implies without an order by, no row number can be assigned. Share.
Read more >The 'ORDER BY' Clause is Missing from the QUERY Column ...
Oracle Database - Enterprise Edition - Version 11.2.0.1 and later: The 'ORDER BY' Clause is Missing from the QUERY Column in DBA_MVIEWS.
Read more >Missing order by due time - Tips and Tricks
After they launched their new 7 Day Calendar View we have a problem: “The missing order by due time is very crucial to...
Read more >List of all missing order numbers that are not in the table
ORDER BY items must appear in the select list if the statement contains a UNION, INTERSECT or EXCEPT operator. sql-server · order-by ·...
Read more >Missing order reasons and how to resolve them?
Some orders are unplanned, follow these steps below to check the reasons of those orders. Step 1: Go to [Transportation], Click on the...
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
A a very simple example where items are not returned in the order they are inserted:
https://docs.microsoft.com/en-us/ef/core/what-is-new/ef-core-6.0/whatsnew#distinct-queries
@roji @ajcvickers why are there different behaviors on different database providers?