0

I am working with a C# List on which I am performing some LINQ query in a C# windows application and I came across a situation where I have to pass a list of strings to a where clause in the LINQ query similar to WHERE Product NOT IN ('sa','as') in SQL, but I am not exactly sure how I can implement in LINQ and pass List of Strings to the query.

FOr a single parameter I am using the following code

 var hiddenProductList = recordsToProcess.Where(x => x.Product != product).ToList();

now I have a list named listProducts and I want to pass this to above query in where and get the results

Is there any way I can implement this?

DoIt
  • 3,270
  • 9
  • 51
  • 103
  • 1
    Asked and answered already - https://stackoverflow.com/questions/3047657/linq-to-sql-in-and-not-in – SLin Jan 07 '15 at 19:42

1 Answers1

6
.Where(x => !listProducts.Contains(x.Product))
Chris Pratt
  • 232,153
  • 36
  • 385
  • 444