Checking if a table contains values in a list

后端 未结 4 712
被撕碎了的回忆
被撕碎了的回忆 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:43

    Try this:

    List TheListParameter = new List{"string1", "string2", "string3"};
    var result = MyDC.SomeTable.ToList().Select(l => l.SomeColumn)
                               .Where(l =>TheListParameter.Contains(l.SomeColumn)).ToList();
    

提交回复
热议问题