Question :
I Am Facing this Error When Decimal Convert issue
The null value cannot be assigned to a member with type decimal which is a non-nullable value type
Answer :
The documentation for Convert.ToDecimal
says that it converts null
to 0
, so it looks like it should work correctly.
--decimal TotalAmount = objTable.Where(x => x.id == XXX).Sum(x =>(decimal?)x.Amount)