How to use the IN operator in linq

后端 未结 1 671
不知归路
不知归路 2020-12-16 22:43

I\'m querying a view and filtering the results with a column named status. I\'d like to query it so I can search for rows with different status, by using the IN operator as

相关标签:
1条回答
  • 2020-12-16 23:46

    If your query expression uses the Contains method of an IEnumerable object, the parser will turn that into an IN expression using the values in the IEnumerable.

    List<string> foo = new List<string>() { "a", "b", "c" };
    
    var query = dataContext.View.Where(v => foo.Contains(v.Status));
    
    0 讨论(0)
提交回复
热议问题