日期:2014-05-20 浏览次数:20724 次
var result = from u in entity.table
group u by new { u.login, u.Goods, u.Date } into temp
select new
{
login = temp.Key.login,
Goods = temp.Key.Goods,
TotalPrice = temp.Sum(c => c.Price),
TotalQty = temp.Sum(c => c.Qty),
BQty = temp.Where(c => c.Key == "B").Sum(c => c.Qty),
SQty = temp.Where(c => c.Key == "S").Sum(c => c.Qty),
Date = temp.FirstOrDefault().Date
};
using (NorthwindEntities entity = new NorthwindEntities())
{
var result = from u in entity.table
group u by new { u.login, u.Goods, u.Date } into temp