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 Core 2.2 group by with where condition evaluated locally #14695

Closed
zulander1 opened this issue Feb 13, 2019 · 1 comment
Closed

EF Core 2.2 group by with where condition evaluated locally #14695

zulander1 opened this issue Feb 13, 2019 · 1 comment

Comments

@zulander1
Copy link

zulander1 commented Feb 13, 2019

I've looked in to isuse 12255 and 14148 it seem be the same thing..

It's wired how the log is showing twice the same message ...

[16:44:21 WRN] Query: '(from Payments <generated>_1 in [tpgrp] select [<generated>_1].Amount).First()' uses First/FirstOrDefault/Last/LastOrDefault operation without OrderBy and filter which may lead to unpredictable results.
[16:44:21 WRN] The LINQ expression 'GroupBy([p].Id, [p])' could not be translated and will be evaluated locally.
[16:44:21 WRN] The LINQ expression 'First()' could not be translated and will be evaluated locally.
[16:44:21 WRN] The LINQ expression 'First()' could not be translated and will be evaluated locally.
[16:44:21 WRN] The LINQ expression 'DefaultIfEmpty()' could not be translated and will be evaluated locally.
[16:44:21 WRN] The LINQ expression 'DefaultIfEmpty()' could not be translated and will be evaluated locally.
[16:44:21 WRN] The LINQ expression 'Sum()' could not be translated and will be evaluated locally.
[16:44:21 WRN] The LINQ expression 'Sum()' could not be translated and will be evaluated locally.
            var query = (from tp in context.TransactionLinePayments.AsNoTracking()
                         join p in context.Payments.AsNoTracking() on tp.PaymentsId equals p.Id
                         where p.Deleted == false
                         group p by p.Id into tpgrp
                         select new { tpgrp.First().Amount }
                       ).Select(x => x.Amount).DefaultIfEmpty().Sum(); 

Entity Framework Core 2.2.0-rtm-35687

EDIT Fixed issue by:

            var query = (from tp in context.TransactionLinePayments.AsNoTracking()
                         join p in context.Payments.AsNoTracking() on tp.PaymentsId equals p.Id
                         where p.Deleted == false && tp.TransactionLine.Deleted == false && tp.TransactionLine.Transaction.Deleted
                         group p by new { p.Id, p.Amount } into tpgrp
                         select new { tpgrp.Key.Amount }
                       ).Select(x => x.Amount).DefaultIfEmpty().Sum();

@smitpatel
Copy link
Member

Duplicate of #12088

@smitpatel smitpatel marked this as a duplicate of #12088 Feb 14, 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