linq小问题

a284280221 2012-09-20 05:53:30

from stg in YTStorageInfo
join ptb in YTPlaceToBarInfo
on stg.SidVch equals ptb.StorageSidVch
join lp in YTLockPlaceInfo
on ptb.StorageSidVch equals lp.FidVch
group new {stg,lp}
by new
{
ptb.PlaceBarVch,
ptb.GoodsBarVch,
ptb.TrayBarVch,
ptb.StorageSidVch
}
into tmp
select new
{
placeBarVch = tmp.Key.PlaceBarVch,
goodsBarVch = tmp.Key.GoodsBarVch,
trayBarVch = tmp.Key.TrayBarVch,
amount = tmp.Sum()//这里报错 实例参数: 无法从“System.Linq.IGrouping<AnonymousType#1,AnonymousType#2>”转换为“System.Linq.IQueryable<int>”
}



刚学linq 希望高手指教
...全文
64 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
a284280221 2012-09-20
  • 打赏
  • 举报
回复
非常感谢
devmiao 2012-09-20
  • 打赏
  • 举报
回复
amount = tmp.Select(y => y.你要求和的属性).Sum()
q107770540 2012-09-20
  • 打赏
  • 举报
回复
tmp里有4个字段,你要为哪个字段进行sum?

amount = tmp.Sum(z=>z.PlaceBarVch)

110,825

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧