vat q = db.tProduct.Where(a => a.ProductID.HasValue && a.Place.HasValue).GroupBy(a => new { a.ProductID, a.Place }).Select(a => new {a.Key,SumQTY=a.Sum(b=>b.Quantity)});
------解决方案--------------------
写法不对。 var result = from t in db.tProduct group t by new { t.ProductID, t.Place} into g select new { g.Key, TotalPrice = g.Sum(t => t.Quantity) };