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

ClientEval when use access annonymous type from an subQuery after Take() #15014

Closed
yyjdelete opened this issue Mar 13, 2019 · 1 comment
Closed

Comments

@yyjdelete
Copy link

Describe what is not working as expected.

Looks similar to #7844?
The below code lead to an client eval, and seems it failed to unpack new { [x].PK }.PK.
But it not failed if Remove Take(), or move Select() after Take(), or not select into an annonymous object(if there is only one key needed)

Steps to reproduce

Include a complete code listing (or project/solution) that we can run to reproduce the issue.

Partial code listings, or multiple fragments of code, will slow down our response or cause us to push the issue back to you to provide code to reproduce the issue.

ctx.Test001
    .Select(x => new { x.PK })
    .Take(20)
    .Select(x => ctx.Test001.Where(x1 => x1.GroupByKey == x.PK).Count())
    .ToList();

->

dbug: Microsoft.EntityFrameworkCore.Query[10101]
      Compiling query model:
      'from <>f__AnonymousType0<int> x in
          (from Test001 x in DbSet<Test001>
          select new { [x].PK }).Take(__p_0)
      select
          (from Test001 x1 in DbSet<Test001>
          where [x1].GroupByKey == [x].PK
          select [x1]).Count()'
warn: Microsoft.EntityFrameworkCore.Query[10102]
      Query: '(from Test001 x in DbSet<Test001> select  (from Test001 x1 in DbSet<Test001> where [x1].GroupByKey =...' uses a row limiting operation (Skip/Take) without OrderBy which may lead to unpredictable results.
dbug: Microsoft.EntityFrameworkCore.Query[10104]
      Optimized query model:
      '(from Test001 x in DbSet<Test001>
      select
          (from Test001 x1 in DbSet<Test001>
          where [x1].GroupByKey == new { [x].PK }.PK
          select [x1]).Count()).Take(__p_0)'
warn: Microsoft.EntityFrameworkCore.Query[20500]
      The LINQ expression 'where ([x1].GroupByKey == new <>f__AnonymousType0`1(PK = [x].PK).PK)' could not be translated and will be evaluated locally.

Further technical details

EF Core version: 3.0.0-preview3.19153.1(also not works in old versions)
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system:
IDE: (e.g. Visual Studio 2017 15.4)

@smitpatel
Copy link
Contributor

Duplicate of #14515

@smitpatel smitpatel marked this as a duplicate of #14515 Mar 13, 2019
@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants