<div mvc-lookup-for="Id" url="People"></div>
public class HomeController : Controller
{
private DbContext Context { get; }
public HomeController(DbContext context)
{
Context = context;
}
[HttpGet]
public JsonResult People(LookupFilter filter)
{
return Json(new PeopleLookup(Context) { Filter = filter }.GetData());
}
}
public class Person
{
...
[Display(Name = "Birthday")]
[LookupColumn(Format = "{0:d}")]
public DateTime Birthday { get; set; }
...
}
public class PeopleLookup : ALookup<Person>
{
private DbContext Context { get; }
public PeopleLookup(DbContext context)
{
Context = context;
FilterCase = LookupFilterCase.Lower;
// Defaults to property with a name "Id".
GetId = (model) => model.Id;
// Defaults to first visible column.
GetLabel = (model) => model.Name + " " + model.Surname;
}
public override IQueryable<Person> GetModels()
{
return Context.Set<Person>();
}
}