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

编程入门 行业动态 更新时间:2024-10-10 15:24:07
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.

更多推荐

本文发布于:2023-08-08 01:04:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1466666.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:模型   MVC   NET   ASP   map

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!