-
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
EF.Property called with wrong property name when using System.Linq.Dynamic.Core OrderBy on multiple columns #19838
Comments
Duplicate of #18904 |
Hi @smitpatel , The workaround you've provided in #18904 is not useful to us as we are using System.Linq.Dynamic.Core, so we cannot really expand the query the way you have specified. Can you provide workaround for this particular issue, or at least ETA on when appropriate fix can be expected? |
The fix will be released in EF Core 5.0 which is tentative going RTM this November. var entities = dbContext.Entities
.Join(dbContext.Resources,
e => e.NameId,
i => i.Id,
(o, i) => new { Entity = o, Name = i })
.Join(dbContext.Resources,
e => e.Entity.DescriptionId,
i => i.Id,
(o, i) => new { Entity = o.Entity, Name = o.Name, Description = i })
.Select(e => new EntityDto
{
NameFormatted = e.Name.Translations
.Where(x => x.LocaleId == localeId)
.Select(x => x.Value)
.FirstOrDefault(),
DescriptionFormatted = e.Description.Translations
.Where(x => x.LocaleId == localeId)
.Select(x => x.Value)
.FirstOrDefault()
})
.OrderBy(e => e.DescriptionFormatted).ThenBy(e => e.NameFormatted)
//.OrderBy($"{col} {ord}")
.ToList(); |
Ok, it seems it works well. We will do more testing and let you know if we notice anything unusual. Thank you! |
We have been using System.Linq.Dynamic.Core for quite some time to generate various dynamic queries. Since upgrade to EF Core 3.0.0/3.1.1, all application queries using .OrderBy("column1,column2 ASC") have stopped to work, with the following exception being thrown:
"EF.Property called with wrong property name".
We have tried to revert back to .NET Core 2.2 / EF Core 2.2.6, and code works as expected.
Steps to reproduce
An example of code that generates this error can be found on this GitHub repository:
https://github.com/App-Impact-Labs/ISSUE-EfCorePropertyCalledWithWrongPropertyName
The code above will create database, seed basic data and generate an error that can be further inspected.
Further technical details
EF Core version: 3.0.0 - 3.1.1
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET Core 3.0 - 3.1
Operating system: Windows 10 x64, Windows Server 2016 x64
IDE: e.g. Visual Studio 2019 16.3
The text was updated successfully, but these errors were encountered: