Hi guys,I get an exception saying "Value cannot be null" when i execute this query (NH 3.3.3):var total = query.Sum(x => x.Income);The exception happens when the query returns no result.I found there's already a Jira issue about this:But why won't fix? It's really not usable if this query throws exception. In every application that need to do reporting will encounter this.And this violate the semantic of the sum and linq to objects, right?If this should throw exception, why query.Count() don't throws?(I understand the technical reason of this, just saying why the semantic of these are not consistent)If L2S or EF behaves the same, I think it's their bug. Not because it's a good thing.Workaounds like this "var sum = myQuery.Sum(x => (int?)x.Prop) ?? 0" make my code really ugly.Ideas?
Mouhong
--
---
You received this message because you are subscribed to the Google Groups "nhibernate-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nhibernate-develo...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
but make it returns 0 and not throwing exception is not "surprise" right? but the exception is "surprise". If in EF user use the same workaround, when he turn to NH, that workaroud is still working, so it doesn't break anything, so there's no "surprise".
You received this message because you are subscribed to a topic in the Google Groups "nhibernate-development" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nhibernate-development/o5orsYz7Ums/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nhibernate-develo...@googlegroups.com.
That make sense if it has technical reason :) I thought there's no technical reason, but just because the team want to keep the behavior same as EF.