///分组
var ArticleGroupData = from row in dataTable.AsEnumerable()
group row by row.Field
select new
{
groupid= Item.Key,
Rows = Item
};
//分组-筛查-排序
var GroupData = dataTable.AsEnumerable()
.Where(row => row.Field
.GroupBy(row => row.Field
.Select(group => new
{
groupid= group.Key,
TotalValue = group.Count() //条数汇总
})
.OrderByDescending(x => x.TotalValue ) // 按汇总数量降序排序
.Take(3).ToList();// 取出数量排前三的分组
//分组-筛查-多条件排序
var filterArticle = dtArticle.Select($"这里写筛查条件")
.Select(Item => new
{
KeyValue= Item.Field
FirstValue = !string.IsNullOrEmpty(Item.Field
SencondValue = string.IsNullOrEmpty(Item.Field
Row = Item
})
.OrderByDescending(x => x.FirstValue) // 首先根据条件1降序排序
.ThenByDescending(x => x.SencondValue) // 然后根据条件2降序排序
.Take(10).ToList();// 取出数量排前10的数据