在Linq中不允许算术运算符。它给错误+不能应用于lambda表达式。 CostperResponse.Cost是数据类型小数的linq中的算术运算符
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)))
};
SQLServer的查询是
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
你正在尝试添加两个lambda表达式,这可能不是你在做什么之后? – lbergnehr
'x'从哪里来? – Jon
你必须引入变量'let'operator –