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

Query: Exception when using the "let" keyword and grouping #3676

Closed
AlekseyMartynov opened this issue Nov 6, 2015 · 2 comments
Closed

Query: Exception when using the "let" keyword and grouping #3676

AlekseyMartynov opened this issue Nov 6, 2015 · 2 comments
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

@AlekseyMartynov
Copy link

Version: 7.0.0-rc1-*

Query:

from p in nwind.Products
let cat = p.CategoryID
group p by cat;
// group p by p.CategoryID; // - also fails when 'let' is present

Message:

Expression of type '...' cannot be used for parameter of type '...' of method '...'

Full sample: https://github.com/AlekseyMartynov/ef7-bugs/tree/group-with-let

@AlekseyMartynov AlekseyMartynov changed the title Using the "let" keyword breaks grouping Usage of the "let" keyword breaks grouping Nov 6, 2015
@rowanmiller rowanmiller added this to the 7.0.0 milestone Nov 6, 2015
@mikary mikary assigned mikary and unassigned maumar Apr 26, 2016
@mikary
Copy link
Contributor

mikary commented Apr 26, 2016

Verified that this query throws an ArgumentException in EntityFramework.MicrosoftSqlServer 7.0.0-rc1-final, but the exception is not thrown in current dev.

The returned results appear to be incorrect due to a related issue (#5179) with navigations.

@mikary
Copy link
Contributor

mikary commented May 4, 2016

Retested now that related issue has been resolved. The initial query completes successfully; however, a NullReferenceException is thrown in LinqOperatorProvider.GetEnumerator when enumerating the elements within the IGrouping<TKey, TElement>

Attempted test in QueryNavigationsTestBase

[ConditionalFact]
public virtual void Let_group_by_nav_prop()
{
    AssertQuery<OrderDetail, IGrouping<string, OrderDetail>>(
        ods => from od in ods
                let customer = od.Order.CustomerID
                group od by customer
                into odg
                select odg,
        asserter: (l2oItems, efItems) =>
        {
            foreach (var pair in
                from l2oItem in l2oItems
                join efItem in efItems on l2oItem.Key equals efItem.Key
                select new { l2oItem, efItem })
            {
                Assert.Equal(
                    pair.l2oItem.Select(i => i.OrderID).OrderBy(i => i),
                    pair.efItem.Select(i => i.OrderID).OrderBy(i => i));
            }
        });
}

@rowanmiller rowanmiller modified the milestones: 1.0.1, 1.0.0 May 4, 2016
mikary added a commit that referenced this issue May 17, 2016
Add test for #3804 - Select Navigation following Skip or Take
Add test for #3674 - GroupBy with Where on Navigation Property
Add test for #3676 - GroupBy Let on Navigation Property (disabled)
Add test for #3913 - Sum + Count inside Select
mikary added a commit that referenced this issue May 17, 2016
Add test for #3804 - Select Navigation following Skip or Take
Add test for #3674 - GroupBy with Where on Navigation Property
Add test for #3676 - GroupBy Let on Navigation Property (disabled)
Add test for #3913 - Sum + Count inside Select
anpete added a commit that referenced this issue Jun 30, 2016
Fix: #3676 - Usage of the "let" keyword breaks grouping.
 - Fixed compiler bug in tracked, grouped queries.
Fix: #5427 - A column has been specified more than once in the order by list thrown for a complex query with orderby and navigation.
 - Fixed bug in SelectExpression.PrependToOrderBy
Fix: #4539 - Query :: Join flattening fails for some complex cases involving SelectMany
 - SelectMany after GroupJoin should not cause client-eval.

Also addressed most of the R# warnings in nav. rewriter.
anpete added a commit that referenced this issue Jun 30, 2016
Fix: #3676 - Usage of the "let" keyword breaks grouping.
 - Fixed compiler bug in tracked, grouped queries.
Fix: #5427 - A column has been specified more than once in the order by list thrown for a complex query with orderby and navigation.
 - Fixed bug in SelectExpression.PrependToOrderBy
Fix: #4539 - Query :: Join flattening fails for some complex cases involving SelectMany
 - SelectMany after GroupJoin should not cause client-eval.

Also addressed most of the R# warnings in nav. rewriter.
anpete added a commit that referenced this issue Jun 30, 2016
Fix: #3676 - Usage of the "let" keyword breaks grouping.
 - Fixed compiler bug in tracked, grouped queries.
Fix: #5427 - A column has been specified more than once in the order by list thrown for a complex query with orderby and navigation.
 - Fixed bug in SelectExpression.PrependToOrderBy
Fix: #4539 - Query :: Join flattening fails for some complex cases involving SelectMany
 - SelectMany after GroupJoin should not cause client-eval.

Also addressed most of the R# warnings in nav. rewriter.
@rowanmiller rowanmiller modified the milestones: 1.0.1, 1.1.0 Jul 1, 2016
anpete added a commit that referenced this issue Jul 1, 2016
Fix: #3676 - Usage of the "let" keyword breaks grouping.
 - Fixed compiler bug in tracked, grouped queries.
Fix: #5427 - A column has been specified more than once in the order by list thrown for a complex query with orderby and navigation.
 - Fixed bug in SelectExpression.PrependToOrderBy
Fix: #4539 - Query :: Join flattening fails for some complex cases involving SelectMany
 - SelectMany after GroupJoin should not cause client-eval.

Also addressed most of the R# warnings in nav. rewriter.
anpete added a commit that referenced this issue Jul 3, 2016
Fix: #3676 - Usage of the "let" keyword breaks grouping.
 - Fixed compiler bug in tracked, grouped queries.
Fix: #5427 - A column has been specified more than once in the order by list thrown for a complex query with orderby and navigation.
 - Fixed bug in SelectExpression.PrependToOrderBy
Fix: #4539 - Query :: Join flattening fails for some complex cases involving SelectMany
 - SelectMany after GroupJoin should not cause client-eval.

Also addressed most of the R# warnings in nav. rewriter.
@anpete anpete closed this as completed in bd1aa14 Jul 4, 2016
@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 Jul 8, 2016
@anpete anpete removed their assignment Jul 8, 2016
@rowanmiller rowanmiller changed the title Usage of the "let" keyword breaks grouping Query: Exception when using the "let" keyword and grouping Jul 21, 2016
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

6 participants