LINQ相当于什么
SELECT primaryID, name, description, unit, SUM(price)
FROM Product
JOIN so that same Products are returned multiple times
GROUP BY primaryID
(from item in dbContext.products
join some join statement that will make products return multiple times
group item by item.primaryID into g
select new {id = key, summedPrice = g.Sum(x => x.price)}
)
但是这样,我只得到ID和总数。我怎样才能得到其他字段?
我想我可以让我的键成为一个annon类,它包含我需要的所有列,但我确定这是否会影响性能,如下所示:
group item by new { item.primaryID, item.name, item.description...} into g