c# - How to search any items of a list within a string using Linq -


i going write search query. in query have list of string this:

var listwords=new list<string>(){"hello","home","dog","what"}; 

and have list of customers. how can search if customer's name contains @ least 1 of items in listwords:

  • jack home

  • hot dog

  • what big dog

tried:

var prodlist = events.where(x =>listwords.indexof(x.name.trim().tolower()) != -1).tolist(); 

use .where , .any:

var result = events.where(c => listwords.any(w => c.name.contains(w))); 

problem solution converting string lower case collection of words has characters in upper case. in case not find match: how can make array.contains case-insensitive on string array?


Comments

Popular posts from this blog

sql - Time in datatime field -

javascript - How to split the success output from an Ajax post? -

java - sharing object across different classes -