This method throws exception when db.Profits
doesn't have any records. How to prevent explode page
public double getProfitSum()
{
return db.Profits.Where(p => p.IdUser.UserId == WebSecurity.CurrentUserId).Sum(p => p.Value);
}
Error :
The cast to value type 'Double' failed because the materialized value is null. Either the result type's generic parameter or the query must use a nullable type.