How to use Linq to check if a list of strings contains any string in a list

后端 未结 5 1555
别跟我提以往
别跟我提以往 2021-02-05 07:12

I\'m constructing a linq query that will check is a string in the DB contains any of the strings in a list of strings.

Something like.

query = query.Whe         


        
5条回答
  •  攒了一身酷
    2021-02-05 07:28

    I've done something like this before:

    var myList = new List();
    myList.Add("One");
    myList.Add("Two");
    
    var matches = query.Where(x => myList.Any(y => x.tags.Contains(y)));
    

提交回复
热议问题