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.

Include 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:closed
  • Created 2 years ago
  • Comments:19 (19 by maintainers)

github_iconTop GitHub Comments

3reactions
ajcvickerscommented, Sep 3, 2021

A a very simple example where items are not returned in the order they are inserted:

var hashSet = new HashSet<int>();
for (var i = 0; i < 10; i++)
{
    hashSet.Add(i);
}

hashSet.Remove(2);
hashSet.Add(1000);

foreach (var i in hashSet)
{
    Console.WriteLine(i);
}
C:/local/AllTogetherNow/FiveOh/bin/Debug/net5.0/FiveOh.exe
0
1
1000
3
4
5
6
7
8
9
2reactions
Varorbccommented, Nov 2, 2021
Read more comments on GitHub >

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

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