Linq to SQL how to do “where [column] in (list of values)”

前端 未结 5 1703
情话喂你
情话喂你 2020-11-29 20:43

I have a function where I get a list of ids, and I need to return the a list matching a description that is associated with the id. E.g.:

public class CodeDa         


        
5条回答
  •  情深已故
    2020-11-29 21:23

    You could also use:

    List codes = new List();
    
    codes.add(1);
    codes.add(2);
    
    var foo = from codeData in channel.AsQueryable()
              where codes.Any(code => codeData.CodeID.Equals(code))
              select codeData;
    

提交回复
热议问题