C# lamda表达式 参考一下 分组
aResults = userStateList.GroupBy(n => n.UserId).Select(g =>
{
return new { UserId = g.Key, xxDuration = xxx };
})
.Where(n => n.UserId > 0)
.GroupBy(n => new { n.UserId, n.xxDuration })
.Select(g => new UserOnlineTime
{
UserId = g.Key.UserId,
UserName = userStateList.Where(c => c.UserId == g.Key.UserId).Select(c => c.UserName).FirstOrDefault(),
Duration = (int)g.Key.xxDuration
}).ToList();