decimal emWeight = context.EMTransactions.Where(r => r.TransactionHeaders_Id == transactionHeaders_Id).Sum(r => (decimal?)r.Weight) ?? 0;
decimal detailsWeight = context.TransactionDetails.Where(r => (r.TransactionHeaders_Id == transactionHeaders_Id)).Sum(r => r.Weight);
return emWeight - detailsWeight;
This indeed works. If I'm right
Sum(r => (decimal?)r.Weight)
the (decimal?) type definition applies to Sum() because Weight is defined a non nullable in my SQL table.
Many thanks for your help.
If things have the tendency to go your way, do not worry. It won't last. Jules Renard.