I am currently converting a stored procedure from an old system by some old programmers into a linq but I can't figure out what is causing this error. The code is as follows:
Controller:
var ObligationRequestDetailsTotalCostByOoe = (from p in db.iBudget_ObligationRequestDetails
where p.ooe_general_id != null && p.is_approved == 1
group p by p.ooe_general_id into g
select new
{
id = g.Key,
amount = g.Sum(p => Convert.ToDouble(p.amount))
}).ToList();
Model:
public int id { get; set; }
public string amount { get; set; }
I tried to change Convert.ToDouble() to Double.Parse() but this error 'Single Parse(System.String)' showed. I tried to add 'System.Globalization.CultureInfo.InvariantCulture' after the p.amount but still the error persist.
What am I doing wrong here? Thanks in advance.