I am working on a web application which uses EF with mysql. The search is getting complicated so i thought about creating a searchTable where i will put all my data which are required for search filters. works pretty well for one to one tables but what about one to many, how should I save that in one row? for example experiences or qualifications etc. the problem is how to put that part in search criteria in EF/Linq? like get users who have the qualification mba.
for (int i = 0; i < searchFilter.Count; i++)
{
keyValuePair = searchFilter.ElementAt(i);
if (keyValuePair.Key.Equals("FullName"))
{
whereClause.Add("FullName.Contains(@" + i + ")");
whereValues.Add(keyValuePair.Value);
}
....
if (keyValuePair.Key.Equals("City"))
{
whereClause.Add("AddressCity.Contains(@" + i + ")");
whereValues.Add(keyValuePair.Value);
}
}
StringBuilder str = new StringBuilder();
for (int i = 0; i < whereClause.Count; i++)
{
str.Append(whereClause[i]).Append(" && ");
}
string strWhere = str.ToString().TrimEnd(" && "); //hypothetical code
AcmeDB db = new AcmeDB();
var searchResult = db.SearchSummaries.Where(strWhere, whereValues);
return searchResult;
Now if i want to search through lets say experiences, how to do that? because this table contains everything i need to search from in single row per user, so i want to have name,username, address, qualifications, experiences etc in one row. I hope i am explaining it right?