I'm new to Entity Framework. I need to search this word 'johnny' in text stored in the database. The text is from pdf files. So there are many words in the text columns.
Here is my code
using (var d = new DatabaseContext())
{
var l = d.Pages.Where(x => x.Text.ToLower().Contains(text.ToLower())).ToList();
}
So far the code is working.
But the requirement changed. If the user types in jhonny bravo, the program will have to search for the word jhonny and bravo in the Text column. The jhonny and bravo should be found, even if the words in the Text column are:
Jhonny is bravo
jhonny is not bravo
How can I solve this?
I came up with the idea that split the text and search for each word
using (var d = new DatabaseContext())
{
var split = Regex.Split(text, @"\s+");
if (split.Count() > 1)
{
var l = d.Pages.Where(x => x.Text.ToLower().Contains(text.ToLower())).ToList();
}
}
But using the code above. How can I create a dynamic search? What if the search term contains 6 words? How can I do the query? Thank you.