LINQ Multiple LIKE based on List

后端 未结 2 783
误落风尘
误落风尘 2021-01-07 02:38

I have a list of keywords in an ArrayList and I wanted to be able to build a query to find records in a table based on this keywords.

Since the list of keywords is d

相关标签:
2条回答
  • 2021-01-07 02:49

    This oughtta do it:

    var query = table.Where(p => keywords.Any(kw => p.Name.StartsWith(kw)));
    
    0 讨论(0)
  • 2021-01-07 03:12
    var query = table.Where(p => keywords.Any(kw => p.Name.StartsWith(keyword1) || p.Name.StartsWith(keyword2) || p.Name.StartsWith(keyword3) || p.Name.StartsWith(keyword4)));
    

    Hope it can help you and have a nice day.

    0 讨论(0)
提交回复
热议问题