I can't figure out why this is failing to cast. It says it is null, but that should never be the case because I'm checking if it's null and replacing it with 0, right?
var BF = (double)filtered.Sum(s => s.fees
.Where(w => w.status == "B")
.Sum(su => su.amount ?? 0));
ERR: The cast to value type 'System.Decimal' failed because the materialized value is null. Either the result type's generic parameter or the query must use a nullable type.
I have a list of objects that each contain a list of fees
which contain a nullable decimal amount
and I just need to sum up the amounts. What am I missing?