I have a column called Title in the DB.
and i have a search term coming from the app.
What i have done so far is this:
var valsSearch = value.searchTerm.ToLower().Split(" ");
var results = ctx.Links.Select(x =>x.Title).Where(x => valsSearch.Contains(x)).ToList();
For example the Title in the DB might be "Ronaldo scores a hattrick" and the searchTerm may be "scores ronaldo"
How do i filter the results when comparing the Title in DB to the searchTerm?
The result should be that the searchTerm when separated are used to filter the values in the Title DB and if there's a match return the result.
CodePudding user response:
Try this,
var valsSearch = value.searchTerm.ToLower().Split(" ");
var results = ctx.Links.AsEnumerable().Where(x => valsSearch.Any(y => x.Title.ToLower().Contains(y))).ToList();