-
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: compilation error for complex query with group by and correlated subquery #11178
Comments
GroupByAggregateTranslatingExpressionVisitor.CanTranslate() tries to extract ShapedQuery from _queryModel.Expression. It doesn't take into account that expression can have InjectParameters around it. |
not needed. |
I have the same exception with more simple example: public class User
{
public int Id { get; set; }
public List<Post> Posts { get; set; }
}
public class Post
{
public int Id { get; set; }
public bool IsDeleted { get; set; }
}
IEnumerable<Post> posts = context.Users
.Select(u => u.Posts
.Where(p => !p.IsDeleted)) // throws same Exception
.FirstOrDefault(); But if we select List<Post> posts = context.Users
.Select(u => u.Posts
.Where(p => !p.IsDeleted)
.ToList()) // works Ok
.FirstOrDefault(); Also, if we rewrite the original query with var query = ctx.Parents
.Select(p => new
{
ParentId = p.Id,
Bars = p.Children
.Select(c => c.Group)
.GroupBy(g => g)
.Select(g => new
{
Group = g.Key,
GroupCount = g.Count()
})
.ToList() // <---
})
.ToList(); |
@maumar - Can you run the first query in current dev? |
@smitpatel repros in current dev |
@maumar please create the new issue and put this back in the backlog. |
filed #11403 |
In the above query Bars requires correlation predicate with outer to effectively generate the collection. Due to GroupBy we cannot add additional column hence it cannot be translated to server. |
query:
throws:
The text was updated successfully, but these errors were encountered: