Link to home
Start Free TrialLog in
Avatar of countrymeister
countrymeister

asked on

Linq to select select top 1

I need to get a row from my gneic list where the BusDate is less than a variable date.
The qualifying date should be the max date returned, instead I get the lowest date that qualifies to be less than s.BusDte
I tried first or default

SomeObject s

var result = (from q in list
                                   where q.ID.ToString() == s.ID && q.BusDate <= s.BusDate
                                   select q.Total).Take(1).LastOrDefault();
ASKER CERTIFIED SOLUTION
Avatar of jasonduan
jasonduan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial