-
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
Complex OrderBy+ThenBy throws InvalidOperationException #18904
Labels
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
customer-reported
Servicing-approved
type-bug
Milestone
Comments
smitpatel
added a commit
that referenced
this issue
Nov 14, 2019
@smitpatel woah that was lightning fast 😮 I assume this will be in 3.1 ? |
@fschlaef - 3.1 is already closed for anymore changes. This would be included in next release after 3.1. I will look into writing a work-around for you in 3.1. |
Work-around: Basically expand all reference navigations being used in ThenBy clause using join before applying OrderBy var crash = context.CustomerData
.Join(context.Set<Customer>(),
cd => cd.CustomerFk,
c => c.Id,
(cd, c) => new { cd, c })
.Join(context.Set<Country>(),
ti => ti.c.CountryFk,
c => c.Id,
(ti, c) => new { CustomerData = ti.cd, Customer = ti.c, Country = c })
.Select(ti => new
{
ti.CustomerData.Id,
InvoiceCount = ti.Customer.Invoice.Count(),
ti.Country.Code,
})
.OrderBy(por => por.InvoiceCount).ThenBy(por => por.Code)
.ToList(); |
smitpatel
added a commit
that referenced
this issue
Nov 16, 2019
smitpatel
added a commit
that referenced
this issue
Feb 10, 2020
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.
customer-reported
Servicing-approved
type-bug
In a complex scenario, using
.OrderBy().ThenBy()
throws anInvalidOperationException
:Steps to reproduce
ReproOrderByThrowsIOE.zip
Note that the repro also fails for 3.0. Also interesting to note is changing anything in the query (most notably, reversing
OrderBy
&ThenBy
parameters) doesn't throw, so this seems to be a specific case.Further technical details
EF Core version: 3.1-preview3
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET Core 3.1
Operating system: W10 x64
IDE: Visual Studio 2019 16.4
The text was updated successfully, but these errors were encountered: