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