-
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
Null checking in anonymous projection #12412
Comments
… SQL Issue: The issue here is, we had projection of kind `nav.Id == null ? null : new { nav.Property }` When it is single property access, we can remove null check since SQL is null safe. Same is not true for anonymous type since it has no SQL equivalent. Anonyous type produces Expression[] in sql translation and we tried to print it out in SQL causing exception. Fix: Fix is to skip over NewExpression/MemberInitExpression so that if we encounter those, we don't go inside of them. Resolves #12412
@peterjanto - Thanks for the repro. |
… SQL Issue: The issue here is, we had projection of kind `nav.Id == null ? null : new { nav.Property }` When it is single property access, we can remove null check since SQL is null safe. Same is not true for anonymous type since it has no SQL equivalent. Anonyous type produces Expression[] in sql translation and we tried to print it out in SQL causing exception. Fix: Fix is to skip over NewExpression/MemberInitExpression so that if we encounter those, we don't go inside of them. Resolves #12412
@smitpatel This issue is approved for patch and the release\2.1 branch is now open for merging. Please ensure:
|
Hello, Thanks for fix ! But when i use something like this modelBuilder.Entity<Address>().OwnsOne(x => x.Turnovers); EF core throw this exception:
Further technical detailsEF Core version: 2.1.2 |
This is the SQL which fails SELECT [x.Posts].[Id], [x.Posts].[PostTurnOver_Value], [t].[Id], NULL, [x.Posts].[PostTurnOver_Value] AS [Value], [x.Posts].[BlogId]
FROM [Posts] AS [x.Posts]
INNER JOIN (
SELECT [x0].[Id]
FROM [Blogs] AS [x0]
) AS [t] ON [x.Posts].[BlogId] = [t].[Id]
ORDER BY [t].[Id] The issue is |
@smitpatel to file a new issue. |
Filed #13157 |
Steps to reproduce
Further technical details
EF Core version: 2.1.1
Database Provider: Microsoft.EntityFrameworkCore.SqlServer 2.1.1
Operating system: WIN10
IDE: Visual Studio 2017 15.7.1
The text was updated successfully, but these errors were encountered: