I have a Linq collection of Things, where Thing has an Amount (decimal) property.
Things
Thing
Amount
I\'m trying to do an aggregate on this for a
To get a non-nullable result, you need to cast the amount to a nullable type, and then handle the case of Sum returning null.
Sum
decimal total = myThings.Sum(t => (decimal?)t.Amount) ?? 0;
There's another question devoted to the (ir)rationale.