<div mvc-lookup-for="Id" url="People" title="People" browser="false"></div>
<div mvc-lookup-for="Id" url="People" title="People"></div>
<div mvc-lookup="Ids" url="People" title="People" value="new[] { 3, 4 }"></div>
public class HomeController : Controller
{
private DbContext Context { get; }
public HomeController(DbContext context)
{
Context = context;
}
[HttpGet]
public ActionResult Index()
{
return View(Context.Set<Person>().Find(2));
}
[HttpGet]
public JsonResult People(LookupFilter filter)
{
PeopleLookup lookup = new PeopleLookup(Context);
lookup.Filter = filter;
return Json(lookup.GetData());
}
}
public class PeopleLookup : ALookup<Person>
{
private DbContext Context { get; }
public PeopleLookup(DbContext context)
{
Context = context;
FilterCase = LookupFilterCase.Lower;
}
public override IQueryable<Person> GetModels()
{
return Context.Set<Person>();
}
}
public class Person
{
[Key]
public Int32 Id { get; set; }
[LookupColumn]
[Display(Name = "Name")]
public String Name { get; set; }
[LookupColumn]
[Display(Name = "Surname")]
public String Surname { get; set; }
[LookupColumn]
[Display(Name = "Income")]
public Int32? Income { get; set; }
[Display(Name = "Birthday")]
[LookupColumn(Format = "{0:d}")]
public DateTime Birthday { get; set; }
}