What is the problem with this query and how can I fix it?
public JsonResult Find(string q)
{
var k = new List<string>(q.Split(' '));
return Json(_dataContext.Jobs
.OrderBy(p => new List<string>(p.Keywords.Split(' ')).Where(n => k.Contains(n)).Count())
.Select(p => new { p.Title, p.IsFullTime, p.Location, p.Category, p.Url, p.Id }),
JsonRequestBehavior.AllowGet);
}
It throws:
Method 'System.String[] Split(Char[])' has no supported translation to SQL.
It's supposed to order the results by shared words between q
and the Keywords
for each row so the more you have shared words, you are ordered higher.
Thanks.
BTW: If it's possible to use Lucene.NET to improve this code, I'd happy to see a short example :)