Skip to content
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

Max causes QueryClientEvaluationWarning #9726

Closed
slubowsky opened this issue Sep 7, 2017 · 2 comments
Closed

Max causes QueryClientEvaluationWarning #9726

slubowsky opened this issue Sep 7, 2017 · 2 comments
Assignees
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@slubowsky
Copy link

Using Max in a Linq query causes QueryClientEvaluationWarning to be thrown but if not configured to throw on this warning then looking at the generated SQL I can see that the Max is actually done on the server, not on the client.

My code:

await context.People.Where(a => a.CompanyId == companyId).MaxAsync(or => or.SystemNumber)

The generated SQL (seen in log and profiler) when not throwing on warning:

SELECT MAX([a].[SystemNumber])
FROM [People] AS [a]
WHERE [a].[CompanyId] = @__companyId_0

Exception message when configured to throw on warning:
Warning as error exception for warning 'Microsoft.EntityFrameworkCore.Query.QueryClientEvaluationWarning': The LINQ expression 'Max()' could not be translated and will be evaluated locally. To suppress this Exception use the DbContextOptionsBuilder.ConfigureWarnings API. ConfigureWarnings can be used when overriding the DbContext.OnConfiguring method or using AddDbContext on the application service provider.

Further technical details

EF Core version: 2.0.0 (and latest 2.1.0 preview)
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: Windows 10
IDE: e.g. Visual Studio 2017

@smitpatel
Copy link
Member

Duplicate of #9516

@anpete
Copy link
Contributor

anpete commented Sep 8, 2017

It looks like we are incorrectly producing the client-eval warning in this case. We are setting RequiresClientResultOperator = true, which causes the warning to be generated. We need to set that flag sometimes, but probably don't for a top-level query.

@anpete anpete reopened this Sep 8, 2017
@ajcvickers ajcvickers added this to the 2.1.0 milestone Sep 8, 2017
@ajcvickers ajcvickers modified the milestones: 2.1.0-preview1, 2.1.0 Jan 17, 2018
anpete added a commit that referenced this issue Jan 24, 2018
No need to generate a warning unless we are in a subquery.
anpete added a commit that referenced this issue Jan 24, 2018
No need to generate a warning unless we are in a subquery.
@anpete anpete closed this as completed in 6c85078 Jan 24, 2018
@anpete anpete added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Jan 24, 2018
@ajcvickers ajcvickers modified the milestones: 2.1.0-preview2, 2.1.0 Nov 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

No branches or pull requests

4 participants