简体   繁体   English

具有n层架构的Asp.Net MVC项目

[英]Asp.Net MVC project with n-tier architecture

I want to asp.net mvc project using n-tier architecture. 我想使用n层体系结构的asp.net mvc项目。 I have Confused in that issue; 我对此感到困惑;

I have 4 tiers that are BLL , DAL , Entities and WebUI . 我有4个层,分别是BLLDAL实体WebUI WebUI tier is a asp.net mvc project. WebUI层是一个asp.net mvc项目。 I added data model into entities tier. 我将数据模型添加到实体层。 In DAL , I create some classes about crud opparations using entity framework. DAL中 ,我使用实体框架创建了一些关于原始操作的类。 Finally I serve this classes as repositories on BLL . 最后,我将此类用作BLL的存储库。 BLL knows DAL and entities tiers, DAL knows entites tier and WebUI is only knows BLL . BLL知道DAL实体,DAL知道的entites层和WebUI知道BLL。 In WebUI , I can access repositories where is into BLL . WebUI中 ,我可以访问BLL中的存储库。 But this repositories' return values are entity classes. 但是,此存储库的返回值是实体类。 I have to give a reference from entities to WebUI tier. 我必须提供从实体WebUI层的参考。 I don't want that WebUI accesses databese directly . 我不希望WebUI 直接访问数据库。 It should access database using repositories inside BLL . 它应该使用BLL中的存储库访问数据库。

What should I do? 我该怎么办? I want to do right thing. 我想做正确的事。 Is anything wrong my architecture? 我的体系结构有问题吗?

Thanks for helping answers. 感谢您的帮助。

You can have another project that has only models for BLLEntities. 您可以拥有另一个仅具有BLLEntities模型的项目。

BLL will always have to map BLLEntities to DALEntities and DALEntities to BLLEnttiies. BLL将始终必须将BLLEntities映射到DALEntities,并将DALEntities映射到BLLEnttiies。

You can use AutoMapper for that. 您可以为此使用AutoMapper。

Any Layer above BLL should deal with BLL entities and not with DALEntities. BLL之上的任何层都应处理BLL实体,而不应处理DALEntities。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM