-
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
Type-Generic Where Clause unable to be translated when using projections (EF Core 3.1.1) #19679
Comments
@maumar to take a look. |
Pinging @maumar |
Seems to be working in current master. [ConditionalFact]
public void Repro19679()
{
using var ctx = new Context19679();
ctx.Database.EnsureDeleted();
ctx.Database.EnsureCreated();
var query = ctx.People.Where(p => new Person19679
{
ContactNumber = p.ContactNumber,
Email = p.Email,
FullName = p.FullName,
Id = p.Id
}.Id.ToString().Contains("0")).ToList();
}
public class Context19679 : DbContext
{
public DbSet<Person19679> People { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer(@"Server=.;Database=Repro19679;Trusted_Connection=True;MultipleActiveResultSets=True");
}
}
public class Person19679
{
public Guid Id { get; set; }
public string ContactNumber { get; set; }
public string Email { get; set; }
public string FullName { get; set; }
} which yields the following sql: SELECT [p].[Id], [p].[ContactNumber], [p].[Email], [p].[FullName]
FROM [People] AS [p]
WHERE CHARINDEX(N'0', CONVERT(VARCHAR(36), [p].[Id])) > 0 |
@tj111 is there more to your query? Translation for ToString should have been present in 3.1.1, so likely something else is wrong. Ideally, please submit full runnable repro, so it's easier for us to pin it down. |
EF Team Triage: Closing this issue as the requested additional details have not been provided and we have been unable to reproduce it. BTW this is a canned response and may have info or details that do not directly apply to this particular issue. While we'd like to spend the time to uniquely address every incoming issue, we get a lot traffic on the EF projects and that is not practical. To ensure we maximize the time we have to work on fixing bugs, implementing new features, etc. we use canned responses for common triage decisions. |
WTF? This is one critical issue and it is super easy reproduced in ef 3.1.1. I am fighting this all the time: ---> System.InvalidOperationException: The LINQ expression 'DbSet Saying "Seems to be working in current master." is an insult to everyone who has to ship something in the timeframe BEFORE 5.0 some point in half a year. This is a regression from 2.2 down into 3.1. it is possibly FIXED in 5.0, but that fix is half a year down the road. Btw., a repro does not even need a database as the test never executed - it blows in the translation phase before opening a database connection. |
May be every issue critical issue. |
The funny thing with EfCore is that the moment you actually try to use it you find out that it is so full of bugs it is not even an alpha. Odata was bad for a time, but the EfCore puts up a new fight on making sure that everyone realizes how much behind even Ef efcore is not - what is it? 10 years? 2.1: Wait . All the while Ef works and works and works and chugs along. And people get told "hey, we fixed that, it does not happen in the branch to be released in more than half a year, you know, go and play with dolls". A case for HR, it seems - there is somethign VERY odd with the way the EfCore teams hadnels this. Paid by Oracle to make MS look bad? |
@maumar your example is using a defined type. If you abstract your person object to a generic the query will fail. And I'm starting to agree with @NetTecture, we are really starting to regret using EF Core for the ORM for a product that is supposed to be shipping this summer. We will spend more time fighting EF than writing functional code on a lot of our development tasks, and it seems there is no hope to getting any issues addressed. |
I have to disagree with you here. There is hope. Hope in the name of 5.0. As someone from the financial markets let me tell you why there is hope. HOPE DIES LAST. When you have moved off to a better product and EfCore is not fixed in 10 years, there STILL is hope left. And this is the ONLY reason why there is still hope. Btw., in another thread - #19830 - @ajcvickers said: "I talk to many developers using EF Core, both posting on here, and big customers running serious apps in major companies (which are sometimes the same)." I find that extremely hard to believe given that it does pretty much not matter what I try, if it is not on the level of Hello World, it blows. |
Duplicate of #19087 |
And the amazing thing here is: This is a one line change with unit tests that was merged in in December and is not in any bug fix. Maybe there would be less bug reports if bug fixes would be deployed? Oh, common sense, you are sooooo lost. |
When trying to access a defined property on a generic, projected type, the object in the
Where
clause lambda is unable to be translated.Outputs:
Steps to reproduce
Stack Trace:
Further technical details
EF Core version: 3.1.1
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET Core 3.1
Operating system: Windows
IDE: Visual Studio 2019 16.4.3
The text was updated successfully, but these errors were encountered: