简体   繁体   中英

Check value in a List<Class> contains in any List<String> usingLambda

I have a List<Expenditure> , in that one column is pptCd(String value). I have one more List<String> which has list of pptCds. I want to get all records in List<Expenditure> which has pptCd in the List<String> using lambda expression. any idea?

private IsValid(List<Expenditure> ExpnTrxs)
    {
        var pptCds = Enum.GetNames(typeof(ReferenceEnums.pptCds));

        var validpptCdsTrxs = AAExpnTrxs.FindAll(x => x.pptCd.);
        var inValidPpptCdsTrxs = AAExpnTrxs.FindAll(x => x.pptCd);

        ....................
        ....................
        ....................
    }

This should do it:

ExpnTrxs.Where(x => pptCds.Contains(x.pptCd)).ToList();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM