如何在linq中基于group count对group by进行排序 [英] How to sort the list based on row count with group by in linq
本文介绍了如何在linq中基于group count对group by进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获取分组上的列表并根据linq中包含的行数对分组列表进行排序。
我该怎么做。请帮助
我尝试过:
how get the list on group by and sort the grouped list based on containing row count in linq.
how can i do this. please help
What I have tried:
var add = attributeValue.OrderByDescending(x => x.AttributeID.Count()).GroupBy(x => x.AttributeID).ToList();
推荐答案
不确定您的数据是什么,但这可能是您正在寻找的:
Not sure what you data is but this may be what you are looking for:
var add = attributeValue.GroupBy(x => x.AttributeID)
.OrderByDescending((x) => x.Count());
这篇关于如何在linq中基于group count对group by进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文