-
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
Projection to SQL fails while using Math.Floor with LINQ Sum expression #27124
Labels
area-query
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
customer-reported
type-bug
Milestone
Comments
For anyone else simplest option to workaround this issue would be multiply everything by one: - var cartsV1 = ctx.Carts.Select(c => new { Cart = c.Name, TotalAmount = c.CartItems.Sum(i => Math.Round(i.Quantity * i.Price, 2)), }).ToList();
+ var cartsV1 = ctx.Carts.Select(c => new { Cart = c.Name, TotalAmount = c.CartItems.Select(i => Math.Round(i.Quantity * i.Price, 2)).Select(t => t * 1).Sum(), }).ToList();
// Desired result: `SUM(ROUND(c.Quantity * c.Price, 2))`
// Workaround solution: `SUM(ROUND(c.Quantity * c.Price, 2) * 1)` From ef core code what I saw, it fails on not being able to extract the type from |
smitpatel
added a commit
that referenced
this issue
May 20, 2022
smitpatel
added
the
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
label
May 20, 2022
ghost
pushed a commit
that referenced
this issue
May 21, 2022
This issue was closed.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area-query
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
customer-reported
type-bug
Bug
Failing to project SQL expression when
Math.Floor
is used insideSum
(if retrieving only sum, no other properties, everything works like expected). By documentation it seems, that it simply should wrap contents withROUND
function.Sample code:
Stack traces:
Provider and version information
EF Core version: 6.0.1
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 6.0
Operating system: Windows 10
IDE: Visual Studio 2022
The text was updated successfully, but these errors were encountered: