我有以下语句,即日志文件中的错误实例。有人可以帮我把它转换成Linq吗?
select
*
from
(
select
distinct
bucket,
count(bucket) as count,
max(error) as error
from
logs
group by
bucket
) a
order by
count desc
答案 0 :(得分:1)
var query = logs
.GroupBy(x=>x.bucket)
.Select
(x=>
new
{
bucket = x.Key,
count = x.Count(z=>z),
error = x.Max(z=>z.error)
}
)
.OrderByDescenting(x=>x.count);