-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Query: Server Eval Count of GroupBy #15097
Comments
Same problem here:
with
|
@MaklaCof - Your groupby query lacks aggregate operator. It can never be translated to SQL GROUP BY clause. |
@myjimmyzhou - Essentially you are counting number of groups. You can just do Distinct on grouping key column and Count on rather than using GroupBy. |
Generated invalid SQL SELECT COUNT(*)
FROM (
SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate]
FROM [Orders] AS [o]
GROUP BY [o].[CustomerID]
) AS [t] |
Work-around public int Count()
{
return webUserDao.DbSet().Where(u => u.CreateTime < DateTime.Now).GroupBy(g => g.UserType).Select(g => g.Key).Count();
} |
Operators covered here
|
Pulling this in 5.0 |
…ot returning group Resolves #15097
code:
Issues:
warn: Microsoft.EntityFrameworkCore.Query[20500]
The LINQ expression 'GroupBy([u].UserType, [u])' could not be translated and will be evaluated locally.
warn: Microsoft.EntityFrameworkCore.Query[20500]
The LINQ expression 'Count()' could not be translated and will be evaluated locally.
warn: Microsoft.EntityFrameworkCore.Query[20500]
The LINQ expression 'Count()' could not be translated and will be evaluated locally.
The text was updated successfully, but these errors were encountered: