.Sum()+.Count() inside .Select can throw exception because .Sum() can be null #3913
Labels
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
type-bug
Milestone
Databases/EF is not my home... I will throw bunch of code and theory and you guys will probably know better if this is bug or not...
I want to display events to volunteer and also number of registered volunteers per event...
Number of volunteers is Count of all Volunteers(Foreign key ManyToMany) + Each volunteer can add few extra volunteers who don't have account on website... ExtraVolunteers...
This produces this SQL:
And throws this exception in aspnet console:
And website says:

Workaround is to change line into:
With workaround produces:
Models:
Extra interesting finding with this code:
It produces this SQL:
Look at placing of ")" for COALESCE, it's after COUNT(*) not before... Feels awkward, but correct(at least in this case) :S
The text was updated successfully, but these errors were encountered: