This is my first asked question on here, and I can't find the answer so apologies if I've missed it somewhere.
I'm currently building a search function in a HR Portal that I'm developing (ASP.NET MVC), and while I've managed to get it all set up to query the SQL Server database I've created, it currently works using a LIKE
query, e.g.:
public List<Detail> Search(List<string> Information)
{
StringBuilder Buildsql = new StringBuilder();
Buildsql.Append("select * from UH_QA.dbo.Answers where ");
foreach (string value in Information)
{
Buildsql.AppendFormat("(Question like '%{0}%') and ", value);
}
string datasql = Buildsql.ToString(0, Buildsql.Length - 5);
return QueryList(datasql);
}
But in order to make sure the search function is fool proof, I want to use a query like this:
SELECT *
FROM UH_QA.dbo.Answers
WHERE CONTAINS(Question, '"Where" OR "do" OR "I" OR "put" OR "my" OR "phone"')
Any advice on how I might be able to go about changing what I've already got to split the string input by the user and then insert the individual words into the query?
My thoughts where to use value.Split(' ')
to split the string by whitespace, but I'm open to suggestions.