symbol time ------ ---------- aaa 2013-04-18 09:10:28.000 bbb 2013-04-18 09:10:27.000 aaa 2013-04-18 09:10:27.000 bbb 2013-04-18 09:10:26.000
对于具有最大时间值的所有不同符号,我需要一行.我如何编写我的LINQ查询?
提前致谢,
from r in Table group r by r.symbol into g select g.OrderByDescending(x => x.time).First()
与方法语法相同:
Table.GroupBy(r => r.symbol) .Select(g => g.OrderByDescending(x => x.time).First());