Linq to sql 具有distinct和order by的查询

Linq to sql 具有distinct和order by的查询,linq-to-sql,Linq To Sql,我有这个数据集 Id TypeId Description ------------------------------- 1 1 happy 2 1 sad 3 2 sad 4 2 sad 5 3 upset 6 1 upset 7 2 chilaxin

我有这个数据集

Id      TypeId      Description
-------------------------------
1       1           happy
2       1           sad
3       2           sad
4       2           sad
5       3           upset
6       1           upset
7       2           chilaxing
8       4           happy
我正试图让LINQ做到这一点:

select count(Id) as count, Type from MyDate
group by Description
order by count desc
所以我得到:

count   Type
------------
3       sad
2       happy
2       upset
1       chilaxing

但我所做的一切都不管用?

你这样做似乎很明显:)
from d in data
group d by d.description into g
orderby g.Count()  desc
select new {g.Key, Count = g.Count()}