此查询从我们的数据库中返回前 25 个畅销产品,按客户:
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);
在这个问题中有人告诉我,我需要在以下行为以下 LINQ 查询创建一个投影:
total_quantity = g.Sum(x => x.MQTY)
请有人能解释一下投影的含义和例子吗?