我需要将该 SQL 查询转换为 Linq:
SELECT
SUM([ArticleAmount]) as amount
,[ArticleName]
FROM [DB].[dbo].[OrderedArticle]
group by articlename
order by amount desc
我尝试了以下代码,但在“a.ArticleName”处出现错误,提示“ArticleName”的定义将丢失。
var sells = orderedArt
.GroupBy(a => a.ArticleName)
.Select(a => new {Amount = a.Sum(b => b.ArticleAmount),Name=a.ArticleName})
.OrderByDescending(a=>a.Amount)
.ToList();
你们中有人知道如何解决这个问题吗?
谢谢你的帮助!