ef/efcore:
以datatype字段分组后按count倒序:
var list=db.table1.GroupBy(x => x.DataType).Select(group=>new { group.Key,Count=group.Count()}).OrderByDescending(x=>x.Count).ToList();
sqlsugar:
sqlsugar groupBy的返回值不是 IQueryable<IGrouping<key,model>>所以写法不同:
client.Queryable<table1>().GroupBy(x => x.DataType).Select(g => new {Id= g.Id, Count=SqlSugar.SqlFunc.AggregateSum(g.Id) })
.MergeTable().OrderBy(x=>x.Count,SqlSugar.OrderByType.Desc).ToList();