//Group PN欄位,總計Instock欄位內數量
var Inventory = (from inv in context.InventoryDatas.ToList()
group inv by inv.PN
into gropData
select new
{
PN = gropData.Key,
Instock = gropData.Sum(s => s.Instock),
}).ToList();
參考資料:
http://www.dotblogs.com.tw/chhuang/archive/2008/05/01/3772.aspx