4

I have multiple attributes say att1,att2,att3 which can be separated by any of the separator. I want to have an "OR" condition in the below query to check if the row value in COLUMN1 is equal or not. Since .Equals can only have a string ,Can any one suggest any other way of doing it.

string result = string.Join(",", attributes);
            List<string> query = (from DataRow dr in response.Output.Tables[0].Rows
                                         where dr["COLUMN1"].ToString().Equals(result)
                                         select dr["COLUMN2"].ToString()).ToList<string>();

1 Answers1

3

Instead of joining attributes to an string, use it's Contains method

List<string> query = (from DataRow dr in response.Output.Tables[0].Rows                                         
                      where attributes.Contains(dr["COLUMN1"].ToString())
                      select dr["COLUMN2"].ToString()).ToList<string>()
Mehrzad Chehraz
  • 5,092
  • 2
  • 17
  • 28