LINQ is it possible to add where clauses dynamically

前端 未结 5 1371
青春惊慌失措
青春惊慌失措 2021-01-05 02:36

I want to search my db with different keys. According to the input, there may be 1 key to 10 keys. Is there a way to add OR/AND clauses to my Linq query dynamically?

5条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-05 03:18

    You could try an .All clause to check all the keys:

    where keys.All(key => feed.content.contains(key))
    

提交回复
热议问题