c# - Need to search multiple words using linq -
i have requirement user comes , enters search words based on need query using linq , display records. eg goes here:
search eg 1: "infosys" if user enters infosys search term can use contains , result easily.
eg 2: "tata consultancy services" if user enters can still use contains , record easily. catch if user enters "tata services" or grammitical mistake "tata constult service" still want show records consists of of 3 words. either tata/consutult/service.
this search dynamic , not restricted 3 array. can split words space.
use any
extension method:
string querystring = "tata services"; var queryparts = querystring.split(' '); var result = records.where(r => queryparts.any(p => r.name.contains(p)));
Comments
Post a Comment