c# - Linq distinct & max -
i have query table:
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
i need one row distinct symbols having biggest time value. how have write linq query?
thanks in advance,
group rows symbol , select each group item max time (table database table name context):
from r in table group r r.symbol g select g.orderbydescending(x => x.time).first()
same method syntax:
table.groupby(r => r.symbol) .select(g => g.orderbydescending(x => x.time).first());
Comments
Post a Comment