linq 中的算术运算符
执行 Linq 中不允许的算术运算符。它给出错误 + 不能应用于 lambda 表达式。 CostperResponse.Cost 的数据类型为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)))
};
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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“意思是”
我不太确定你想将什么分配给成本?
可能你的意思是这样的
但是既然你已经分组了,你将需要使用像 Sum() 等这样的聚合?
"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?