I've created the bulk of a C# application, of which the core is a person database (there's a lot more going on peripherally too). I'm using EF with the CodeFirst/DbContext methodology. For my frontend, I have XAML using a MVVM type approach.
I would now like a search box which "feels" like a free-text search. I currently have an editable combo box, with properties set up to provide the correct feel. I am using EF's "Contains" query method to query the SQL database.
At present, I have something along the following lines:
x.Contains(p=> p.Forenames.Contains(s) || p.Surname.Contains(s))
Which works well to a limited extent. This is obviously a problem if "s", the search string, contains both first name and surname data. In essence, I want the user to be able to search by typing "Joe Bloggs" or "Bloggs, Joe" or various combinations of middle names etc... I may even want to add address data to the search in future.
My question is how I achieve this? The first way that springs to mind is to Split the string and then pass the individual components of the array to each search term, in a foreach loop. This could potentially result in multiple, rather large queries.
Is the a better way to achieve what I want to achieve through using a different query strategy with EF itself? I want to give the user the feeling that any search term they type provides something sensible in the combo box!