c# - How to find the min dates from the list of items? -


i have table structure

id  |  itemid |  date | 1   |  a1     | 6/14/2015 2   |  a1     | 3/14/2015 3   |  a1     | 2/14/2015 4   |  b1     | 6/14/2015 5   |  c1     | 6/14/2015 

from table structure trying distinct items has min date. e.g. trying id = 3,4 , 5.

i have tried following code couldn't

var items = (from in _db.items              //where min(i.date) // doesn't seem right              group i.itemid              d select new              {                  iid = d.key,              }).distinct(); 

given sample data, this:

var query =     in _db.items     group i.itemid gis     let lookup = gis.tolookup(x => x.date, x => x.id)     x in lookup[gis.min(y => y.date)]     select x; 

Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

c# - Exception when attempting to modify Dictionary -