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

EF 6 .0 GroupBy select Top N Query Count() Throw Exception #28353

Closed
ByZhouhang opened this issue Jul 1, 2022 · 1 comment
Closed

EF 6 .0 GroupBy select Top N Query Count() Throw Exception #28353

ByZhouhang opened this issue Jul 1, 2022 · 1 comment

Comments

@ByZhouhang
Copy link

ByZhouhang commented Jul 1, 2022

Include your code

I see in the documentation that ef6.0 support for GroupBy queries
https://docs.microsoft.com/en-us/ef/core/what-is-new/ef-core-6.0/whatsnew#improved-groupby-support

I have a paginated list (grouped to take the first N items), and when I try query.Count(), it throws an exception and does not query the database

var query= context.People
    .Include(e => e.Shoes)
    .GroupBy(e => e.Id)
    .Select(g => { PeopleId=g.key,   Count=g.Shoes.Count(),Top2List=   g.Shoes.take(2)});


var count=query.Count()  //Throw  exception  Nullable object must have a value.
var list =query.ToList()  // can be queried
var list2=query.Skip(0).Take(10).ToList() // can be queried
@ByZhouhang ByZhouhang changed the title EF 6 GroupBy select Top N Query Count() Throw Exception EF 6 .0 GroupBy select Top N Query Count() Throw Exception Jul 1, 2022
@smitpatel
Copy link
Contributor

Duplicate of #27796

@smitpatel smitpatel marked this as a duplicate of #27796 Jul 1, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Jul 5, 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