1

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?

1
  • Could you give a code example of what you are roughly trying to do? I am having a hard time conceptualizing it. It sounds like you are looking for a way to look inside of an XML element in the where clause of a LINQ to SQL code block. Oct 1, 2012 at 13:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.