日期:2014-05-20 浏览次数:20926 次
var query = from o in db.Orders
group o by new { o.PName, CREATEDATE.Year, CREATEDATE.Month } into g
select new {
g.First().SalesID,
g.First().PName,
QUANTITY = g.Sum(x => x.QUANTITY),
AMOUNT = g.Sum(x => x.AMOUNT)
};
var query = from o in db.Orders
let temp=new DateTime(DateTime.Now.Year,DateTime.Now.Month,1)
where o.CREATEDATE.Year<temp && o.CREATEDATE>temp.AddMonth(-1)
group o by o.PName into g