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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -