ASP NET solution we are working on consists of multiple layers, user interface is developed using asp net mvc 2 web form view engine with extensively use of template editors and data annotations (recently we upgraded it to asp net mvc 3). For instance, we have Create action in RegistrationController:
[HttpPost]
public ActionResult Create(PersonViewModel person)
{
try
{
if (!ModelState.IsValid)
{
return View(person);
}
else
{
var personInterface = BusinessRegister.PersonHandler.Save(person);
return View("Edit", personInterface);
}
}
catch {
}
}
因此,我们有个人意见书Model,其出席之处是把从浏览器传递的信息与控制器行动联系起来的简单数据传输标。 此外,它叫Handler。 Save (behind this callstay WCF Service responsible for seriesizing transmitted Object into PersonEntity (LLBL Object).
之所以出现这一问题,是因为世界钻石联合会需要合同,所以它不知道与HerViewModel(或如何将其序列化)有何关系,因此,首席建筑师建议直接在有ORM实体的所在地和变更控制人签名的集会上提及。 因此,现在我们的控制者会想像我们的控制者。
[HttpPost]
public ActionResult Create(PersonEntity person)
{
….
I am asking you for help – is it correct doing it this way - putting ORM entity behind default model binder of mvc framework? I am not sure this is best modeling practice -shoudn’t it be viewModel instead so we can later use some kind of mapping to PersonEntity? Or, better, how to avoid tightly coupling here (which is obvious). Thank you in advance.