do arithmetic operators not allowed in Linq. it giving error + can not applied to lambda expression. CostperResponse.Cost is of datatype decimal
var costperrespone= from v in lstSale
group v by v.ActionGroupName into g
select new CostperResponse
{
ActionGroupName = g.Key,
Cost = ((x => Convert.ToDecimal(x.ResponseROCount))) / ((x => Convert.ToDecimal(x.ResponseWPAmount)) + (x => Convert.ToDecimal(x.ResponseWPAmount)))
};
the sqlserver query is
select SUM((cast(isnull(response_ro_count,0) as decimal))/(cast(isnull(response_cp_amount,0)as decimal) + cast(isnull(response_wp_amount,0)as decimal))) , action_group_name from GM_Tempdata where cast(response_ro_count as decimal)>0 group by action_group_name
“means”
I’m not quite sure what you want to assign to Cost?
Possibly you meant something like
But since you’ve grouped, you are going to need to use an aggregate like Sum() etc?