-
Notifications
You must be signed in to change notification settings - Fork 228
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
EF.Functions.Sum
throws
#2569
Comments
Does it work if the thing inside the Sum is a direct property on |
@roji Thank you for the response.
I did provide a very simple repro by the way if that helps. |
Update: I just tested this: var course = db.Videos.GroupBy(_ => true).Select(g => new
{
TotalDuration = EF.Functions.Sum(g.Select(v => v.Duration)),
}).FirstOrDefault(); And it seems to work, so apparently Shouldn't something like |
I'll look into this (but it will probably take some time). |
Duplicate of dotnet/efcore#29200 |
Took a deeper look at this, and it's unfortunately a current limitation of EF (dotnet/efcore#29200) - custom aggregate functions can only be used with GroupBy. For now, until this limitation is lifted, rewrite your query via GroupBy as you've done above. |
(and please upvote dotnet/efcore#29200!) |
Here's a simple repro: https://github.com/aradalvand/efcore-pgsql-bug
Let me know if I'm missing something here because this seems very basic.
I used to have a pretty simple expression to get the sum of a related collection's
TimeSpan
properties:This worked (still does of course), generating the following SQL:
Now, in EF7, with the introduction of provider-specific aggregate functions, I wanted to change the code above to use the
EF.Functions.Sum
method instead — to avoid converting the column into seconds and back:This looks like the most basic usage of this method.
But to my surprise I found out it actually throws:
What's wrong here?!
Thank you in advance.
The text was updated successfully, but these errors were encountered: