Filtering a List using LINQ -
hello have class called empowercalendarcode:
it has following fields calendarcode, calendarname, effectivestartdate, empowertaxtype, longagencycode, taxdepositfrequencybasetypeid.
i want filter list based on longagenycode , empowertaxtype. lets say:
public ilist<empowercalendarcode> getempowercalendarcodes(string longagencycode, string empowertaxtype) { //todo: }
if more 1 empowercalendarcode same longagencycode, empowertaxtype has same taxdepositfrequencybasetypeid , should pick 1 has recent effectivestartdate. how ould able write linq query. okay if have 2 3 queries result.
any ideas , suggestions appreciated!
try this:
ctx.empowercalendarcodes .where(a=>a.longagencycode == longagencycode && a.empowertaxtype == empowertaxtype) .orderbydescending(a=>a.effectivestartdate) .firstordefault();
Comments
Post a Comment