我想生成类似于
的linq查询select distinct HashTagName, count(HashTagName) as CountOf
from tblUserHashTags group by HashTagName order by CountOf desc
请建议我这样做。
答案 0 :(得分:1)
使用查询语法应该非常简单: -
var result = from uh in db.tblUserHashTags
group uh by uh.HashTagName into g
let count = g.Count()
orderby count descending
select new
{
HashTagName = g.Key,
CountOf = count
};