c# - Linq-to-Sql filtering for dates of last element -
i have table looks this:
fruitid | basketid | harvestdate 10 | 435 | 10/1/2014 11 | 430 | 8/4/2014 12 | 435 | 3/1/2014 13 | 430 | 5/2/2014
i want pass in list of basketids , homecoming basketid harvestdate less date. instance, if pass in 430 , 435 , info sep 29 query should homecoming 430 because 435 has fruit 10 has harvestdate past parameter.
this have:
var output = (from f in mydc.fruits thebasketids.contains(f.basketid) && f.harvestdate <= thedate select f.basketid).tolist();
my instinct tells me should grouping basketids match ids passed in , sort harvestdate , take basketids lastly date less date parameter i'm stuck on syntax. how can prepare query?
thanks.
(from f in mydc.fruits grouping f f.basketid g thebasketids.contains(g.key) && g.orderbydescending(gg=>gg.harvestdate).first().harvestdate <= thedate select g.first().basketid).tolist();
c# linq-to-sql
No comments:
Post a Comment