samedi 9 mai 2015

Search for Multiple Values from Multiple Values

I'm looking for a way to use an array of search request to check against the array of the database entries. The solution calls for the ability to search for 1 or more skills attached to an entry, that can have up to 12 skills. I'd ultimately need to rank these results to say how good a match they are to each other.

So, my question is how I loop through the arrays to find all the matches?

I feel like I'm on the right track with this approach, a tip from an earlier question: Search by Multiple Values

        public ActionResult GetSkillList(string term)
    {
        if (!String.IsNullOrEmpty(term))
        {
            string[] items = term.Split(new Char[] { ',' });
            return View(db.Skills.Where(s => s.SkillName.ToLower()
                   .Split(new Char[] { ',' }).Contains(items))
                   .ToList(), JsonRequestBehavior.AllowGet);
        }
        else
        {
            return View(db.Vacancies.Take(0));
        }

    }

At a high level, I'm aiming for the middle part now. High level plan

Aucun commentaire:

Enregistrer un commentaire