I have this code that returns JSon for autocomplete.
public ActionResult AutocompleteCompany(string term)
{
var model = CacheObjects.Companies
.Where(x => x.CompanyName.Contains(term))
.Select(x => new
{
label = x.CompanyName,
id = x.CompanyId
});
return this.Json(model, JsonRequestBehavior.AllowGet);
}
There is a performance issue here because I am newing up the label and id. There must be another way of doing this which is faster?
EDIT - it is probably the Contains clause that is the performance issue here