c# - Filtering results based on date and fetching one previous value -
i have idbset
querying following:
var list = messageset.where(x => x.date >= fromdate && x.date <= todate);
later on other linq queries such select
, orderby
, on.
in order calculate , transform data in way want, need last value before fromdate
, can obtain as:
var prevvalue = messageset.where(x => x.date < fromdate).orderbydescending(x => x.date).firstordefault();
however, doing join
iqueryable
, not working me
is there way combine queries?
can union entries between dates , 1 before?
var list = messageset.where(x => x.date >= fromdate && x.date <= todate) .union(messageset .where(x=>x.date < fromdate).orderbydescending(x=>x.date).take(1) );
Comments
Post a Comment