_investmentRepository.Table.Where(t => t.CustomerId == customerId && t.InvestmentStatus == tempStatus).Sum(t =>t.Amount);
查询结果存在NULL值,在尝试将它转换成System.Int32时出了错,解决方法如下
_investmentRepository.Table.Where(t => t.CustomerId == customerId && t.InvestmentStatus == tempStatus).Sum(t => (decimal?)t.Amount) ?? 0;