Checking if a table contains values in a list

后端 未结 4 711
被撕碎了的回忆
被撕碎了的回忆 2021-01-21 23:26

I have a parameter list of strings and I want to write a query that returns a list of strings that contain values of the parameter list that are present in the table. I have the

4条回答
  •  面向向阳花
    2021-01-21 23:51

    Try following

      List TheListParameter = new List{"string1", "string2", "string3"};
    
      var TheOutput = (from t in MyDC.SomeTable
                       where TheListParameter.Any(e => e == t.SomeColumn)
                       select t.SomeColumn).ToList();
    

提交回复
热议问题