原始数据:
StrDateTime ServerName
9/15/2012 3:01:19 PM 'srvr1'
9/15/2012 3:01:19 PM 'srvr2'
9/15/2012 3:01:19 PM 'srvr33'
9/15/2012 3:02:15 PM 'srvr1'
9/15/2012 3:02:15 PM 'srvr5'
我的代码(not work
):
(from data in dataInToday
group data by data.StrDateTime into grp
let srvrs = (from i in grp select i.ServerName).ToString()
select new
{
grp.Key,
srvrs
}).Take(20).Dump();
预期输出:
Key srvrs
9/15/2012 3:01:19 PM 'srvr1, srvr2, srvr33'
9/15/2012 3:02:15 PM 'srvr1, srvr5'
9/15/2012 3:02:43 PM 'srvr1, srvr2'
9/15/2012 3:03:19 PM 'srvr9, srvr2'
9/15/2012 3:04:19 PM 'srvr5, srvr11'
9/15/2012 3:05:19 PM 'srvr1, srvr2'
是否有 linq 函数可以实现它