0
public class PersonsController : Controller
{
//
// GET: /Persons/
PersonContext PC = new PersonContext();
public ActionResult Index()
{
List<Person> P = PC.person.ToList();
return View(P);
}
public ActionResult Edit()
{
return View();
}
}
这是我的控制器类,我想以列表格式显示我的表格数据。我怎样才能做到这一点?MVC列表中显示的表4
我的模型类是人 和Context类是PersonContext。
我们实际上用mvc中的.Add()方法做了什么? PC.person.Add(PERSON1); PC是我的上下文类的对象,而person是我的模型类Person的属性,但此方法的含义是什么Add(); – 2015-02-11 07:18:04
当您使用列表时,Add()方法只是将人员添加到集合中。但如果我是你,我会使用另一种视角模型,甚至与人类相似。业务逻辑必须与视图分开。 – 2015-02-11 08:55:36