1

Need help in filtering LINQ select query with another List<string>

Like,

List<string> samplingList;

var Result = from F in db.TableA where F.flag == "A" && F.code in (samplingList)

F.Code.Contains() can accept only single value, How can I pass samplingList to LINQ to filter data. Basically I am looking for achieving SQL code value in ('V1', 'V2') in LINQ.

Salah Akbari
  • 39,330
  • 10
  • 79
  • 109
Pradeep H
  • 592
  • 2
  • 7
  • 27

1 Answers1

2

What about this:

samplingList.Contains(F.code)

So your complete query should be something like this:

var Result = from F in db.TableA where F.flag == "A" &&
             samplingList.Contains(F.code)
             select F;
Salah Akbari
  • 39,330
  • 10
  • 79
  • 109