ASP.NET MVC将模型映射到BLL(ASP.NET MVC map Model to BLL)

我有一个用于我的MVC4站点的项目,一个用于我的BLL,一个用于我的DLL。

在我的MVC4站点中,我应该简单地在我的控制器内部新建BLL对象并将它们映射到Model对象吗? 我希望BLL类和Model类保持独立,但我不确定是否应该将它们映射到或者是否有另一种更好的方法。

然而,我想要将模型类与BLL类相关联的方式非常简单。

谢谢

I have a project for my MVC4 site, one for my BLL and one for my DLL.

In my MVC4 site, should I simply, inside my controllers, new up BLL objects and map them to Model objects? I want the BLL classes and Model classes to remain separate, but I am not sure if I should just map them over or if there is another, better way.

I want whatever way I relate the Model classes to their BLL classes to be really simple, however.

Thanks

最满意答案

您可以在控制器或辅助方法中手动进行映射,这对MVC来说很好,但我建议使用像AutoMapper这样的组件进行映射。

同样,automapper是可选的,你可以自己做。

You can do the mapping by hand in your controller or helper methop, that is fine to MVC, but I would suggest doing the mapping using some component like AutoMapper

Again, the automapper is optional, you can do it yourself.

ASP.NET MVC将模型映射到BLL(ASP.NET MVC map Model to BLL)

我有一个用于我的MVC4站点的项目,一个用于我的BLL,一个用于我的DLL。

在我的MVC4站点中,我应该简单地在我的控制器内部新建BLL对象并将它们映射到Model对象吗? 我希望BLL类和Model类保持独立,但我不确定是否应该将它们映射到或者是否有另一种更好的方法。

然而,我想要将模型类与BLL类相关联的方式非常简单。

谢谢

I have a project for my MVC4 site, one for my BLL and one for my DLL.

In my MVC4 site, should I simply, inside my controllers, new up BLL objects and map them to Model objects? I want the BLL classes and Model classes to remain separate, but I am not sure if I should just map them over or if there is another, better way.

I want whatever way I relate the Model classes to their BLL classes to be really simple, however.

Thanks

最满意答案

您可以在控制器或辅助方法中手动进行映射,这对MVC来说很好,但我建议使用像AutoMapper这样的组件进行映射。

同样,automapper是可选的,你可以自己做。

You can do the mapping by hand in your controller or helper methop, that is fine to MVC, but I would suggest doing the mapping using some component like AutoMapper

Again, the automapper is optional, you can do it yourself.