0
該查詢從數據庫返回的前25名暢銷書,由客戶:LINQ和投影的SUM()
var query = from bs in db.MYDATABASE
where bs.COMPANY == "MY COMPANY"
group bs by bs.PRODCODE into g
orderby g.Sum(x => x.MQTY) descending
select new BestSeller
{
product_code = g.Key,
product_description = g.First().DESCRIPTION,
total_quantity = g.Sum(x => x.MQTY)
};
var top25 = query.Take(25);
我一直told in this question,我需要創建以下LINQ查詢在投影以下行:
total_quantity = g.Sum(x => x.MQTY)
請有人可以解釋什麼是投影的意思和這樣的例子?
http://blogs.msdn.com/b/ericwhite/archive/2008/04/22/projection的.aspx – sloth