-
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
Query: Null TypeMapping in Sql Tree #13860
Comments
dupe of #12788 |
Sorry for the dup! :) |
For what it's worth, if I create a "model" type to wrap the id the problem goes away:
To:
|
No worries @kswoll. We decided to use your issue to track this. Thanks for posting the workarounds. |
Hmm, the workaround is kinda messy. But it seems every other workaround gets optimised out. e.g.
This means we need to project into the wrapper private class Workaround13860<T>
{
public T Value { get; set; }
} |
Throws in 3.1
|
My problem is this part of query: |
I'm having a similar problem, except the work around does not work for my case. If I reduce the size of my projection the query works, but does not work with the full projection. Here is the smaller version of the projection:
The issue arises because of the comparison Price = e.Price != null ? ... I define the relationship with SiteProductSourceUrl and SiteProductdPrice as such:
It's a one to one relationship with price being the dependent entity and sourceurl the principle. Here are the relevant models:
Below is the full stack trace.
|
I found a work around, but I don't necessary like the solution. I'm not sure how this will affect performance. In the Source Url Entity Class, I now always initialize the price as an empty POCO
I then changed the query to check with the price id instead of the price reference
Although this works, doing it this way has other negative affects. For example, I have to set any empty prices back to null in other queries using eager loading, otherwise it will try to save an empty price when persisting. |
When using
.Select
to project into custom types you can run into this error when using the conditional operator. I've included a SSCE below, but the gist is this code here:Interestingly, if I remove either the
ThirdEntityId
assignment or theSecondEntity
assignment, there are no problems.The full exception is:
The full repro is to create a new .NET Core Console program, add
Microsoft.EntityFrameworkCore
andMicrosoft.EntityFrameworkCore.Sqlite
and make this your mainProgram.cs
file:Further technical details
EF Core version: 2.1.4
EF Core Sqlite version: 2.1.4
Database Provider: Microsoft.EntityFrameworkCore.Sqlite
Operating system: Windows 10
IDE: Visual Studio 2017 15.8.8
The text was updated successfully, but these errors were encountered: