I am following the tutorial:
http://www.codeproject.com/Articles/762959/jQuery-UI-Autocomplete-in-MVC-Selecting-Nested-Ent
I blocked at the code
public JsonResult GetListForAutocomplete(string term)
{
Person[] matching = string.IsNullOrWhiteSpace(term) ?
db.Persons.ToArray() :
db.Persons.Where(p => p.LastName.ToUpper().StartsWith(term.ToUpper())).ToArray();
return Json(matching.Select(m => new
{
id = m.Id,
value = m.LastName, label = m.ToString()
}), JsonRequestBehavior.AllowGet);
}
I have error on db variable that is not declared. But I don't know how to declare it. The tutorial doesn't mention it.