linq查询一个字段的总和

来源:互联网 发布:发布淘宝优惠券的软件 编辑:程序博客网 时间:2024/05/16 01:16

(from s in dc.StockInItem   //所要查询单表

join si in dc.StockIn           //联合的表

on s.StockInID equals si.StockInID     //两个表联合的相同条件 

where (s.ColorsID == int.Parse(colorID) && s.SizesID == int.Parse(sizeID) && s.ProductID == int.Parse(ProtectID) && si.Status == "Audited") 

//条件

select s.Quantity).Sum()   //查出所有 Quantity 的总和

1 0
原创粉丝点击