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

Shadow property with custom conversion type is not translated to sql. #11379

Closed
rkdrnfds opened this issue Mar 22, 2018 · 1 comment
Closed

Comments

@rkdrnfds
Copy link

rkdrnfds commented Mar 22, 2018

dbContext.Posts.Where(e => EF.Property<BlogId>(e, "BlogId") == blogId).ToList();

and

dbContext.Entry(blog).Collection(e => e.Posts).Load();

generates warning

Microsoft.EntityFrameworkCore.Query[20500]
      The LINQ expression 'where (Property([e], "BlogId") == __blogId_0)' could not be translated and will be evaluated locally.

Post.BlogId Property Is a shadow foreign key to Blog Entity, and also has custom value conversion of EF Core 2.1

dbContext.Entity<Post>()
.Property<BlogId>("BlogId")
.HasConversion(blogIdToGuidConverter)

with primitive type like int, sql translation works well with shadow type.

Environments:

<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.1.0-preview1-final" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.1.0-preview1" />
@smitpatel
Copy link
Contributor

smitpatel commented Mar 22, 2018

Duplicate of #10434

The error here is when we visit the Constant the type is not primitive type which TypeMapper understands. SqlTranslator does not utilize inference so we fail to translate the Constant to server and falls into client eval. If we passed in constant as is (that's what Constant expression translate too) then in this case, it could possible generate SQL literal using the type mapping with converter from left side of equality.

(edit: It has nothing to do with shadow property)

@divega divega closed this as completed Mar 23, 2018
@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

4 participants