0

Please show me how to use "not in" using LINQ

Given the SQL :

select count(*) from Customer
where (ID = @Id and substring(CustomerIndicator, 1, 1) 
not in(@custInd1, @custInd2, @custInd3))

My Attempt:

        var results = (from r in dt.AsEnumerable()
                       where r.Field<string>("ID") == row["ID"].ToString()
                            && !(r.Field<string>("CustomerIndicator").Substring(1, 1) == "X" || "Y" || "Z")
                       select r).Count(); 
User11040
  • 208
  • 1
  • 3
  • 12

0 Answers0