-1

在 SQL 中,我有以下语句说明日志文件中的错误实例。有人可以帮我把它转换成 Linq 吗?

select
    *
from
(
    select
        distinct
        bucket,
        count(bucket) as count, 
        max(error) as error
   from
        logs
   group by
        bucket
) a
order by
    count desc
4

1 回答 1

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);
于 2013-09-15T14:58:43.117 回答