Skip to content

Translate GroupBy followed by FirstOrDefault (and similar) using ROW_NUMBER() #36380

@chenghehe

Description

@chenghehe

What problem are you trying to solve?

var result = await dbContext.YourTable
.GroupBy(e => e.GroupColumn)
.Select(g => g.OrderBy(e => e.SortColumn).FirstOrDefault())
.ToListAsync();

This way of writing will prompt an exception and cannot run

Describe the solution you'd like

No response

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions