score:2
Although EF Core 2.1 introduced improvements to LINQ GroupBy translation, the implementation is still far from perfect and produces exceptions in many scenarios due to invalid SQL generation. Your scenario is just one of them and is not working even with the recent at this time EF Core 2.1.1 bits.
The first thing you should do is to submit it to the EF Core issue tracker, so they know and fix it when possible.
The problem seems to be related to the key property aliasing (it also doesn't work if you use the "normal" .GroupBy(e => e.TypeId).OrderBy(g => g.Key)
). The current workaround I've found is to use anonymous type key having the same property name(s) as the source(s):
_context.MyTable
.GroupBy(e => new { e.TypeId })
.OrderBy(g => g.Key.TypeId)
.Select(g => g.Count())
Source: stackoverflow.com
Related Articles
- GroupBy OrderBy Linq - invalid column
- LINQ Lambda efficiency of code groupby orderby
- LINQ Source Code Available
- multiple orderby in this linq code
- linq after groupby unable to get column values
- Linq Lambda GroupBy and OrderBy
- why Linq GroupBy After OrderBy dismissed order operation?
- LINQ GroupBy then OrderBy Behaviour
- LINQ - sub query using OrderBy and GroupBy
- Linq - OrderBy int column gives incorrect results
- LINQ to SQL: Invalid column name 'DepartureGate', even though the column exists
- creating Linq to sqlite dbml from DbLinq source code
- LINQ Error Invalid Column Name on Group by sum
- How to perform LINQ OrderBy based on a stringname for column
- Linq query giving Invalid column name "xyz" error
- Linq to Entity Groupby and concatinate column
- MVC LINQ dynamic orderBy getting column type
- GroupBy DateTime column with offset C# Linq
- how to groupby on only one column using linq
- Getting 'Data source is an invalid type' when binding Linq query to Gridview
- LINQ Query Exception error Invalid column name 'courseId1' EFCore
- GroupBy and OrderBy in LINQ
- LINQ (Dynamic): OrderBy within a GroupBy using dynamic linq?
- Asp.net LINQ groupby and orderBy on dates does not retrieve the expected output
- Invalid column name. The name was never implemented in the code
- LINQ GroupBy and then OrderBy a property from the previous query
- source code for LINQ 101 samples
- LINQ GroupBy for multiple Column
- Linq GroupBy Max and add column
- LINQ Groupby query on a single column
- More concise LINQ with 'or' clause
- Get custom object from lambda expression
- How to search the XML tag?
- find out the words with substring in LINQ
- How to get missing value from two array in linq considering duplicates
- Double-use of C# iterator works unexpectedly
- Is it possible to create anonymous type in LINQ extension methods in C#?
- What does entity framework .load(MergeOption) do?
- how to make a property of a foreign table appear on datagridview using LINQ?
- Add values in Varray using LINQ
- linq select distinct date from a DataTable
- linq query generate defferent results
- Am I misunderstanding LINQ to SQL .AsEnumerable()?
- C# LINQ single query to complete an incomplete model
- Loop to LINQ Conversion -
- Datatable.Select with Like in VB.net
- C#/LINQ to SQL - order combined results from two different result sets
- Linq fail - A first chance exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.Linq.dll
- How to sort a dictionary by key, if key is a list (in C#)?
- Get Current Identity through Linq