简体   繁体   English

MVC架构

[英]MVC Architecture

I know similar questions have been posted before, but I have specific requirements that make this as far as I can find unanswered.我知道之前已经发布过类似的问题,但我有特定的要求,这使我无法找到答案。

The project wants to have a typical 3-tier architecture, but they want the data layer to be abstracted by Entity Framework, the presentation layer to be MVC 2 and the application layer to be simple class library.项目希望有一个典型的3层架构,但是他们希望数据层被Entity Framework抽象,表现层是MVC 2,应用层是简单的类库。

Do those components (EF and MVC) fit into that architecture.这些组件(EF 和 MVC)是否适合该架构。

Note: the project would follow a TDD methodology.注意:该项目将遵循 TDD 方法。

Any help is appreciated.任何帮助表示赞赏。

Absolutely.绝对地。

Any good demonstration/articles on ASP.NET MVC Web Applications follow this architecture.任何关于 ASP.NET MVC Web 应用程序的优秀演示/文章都遵循此架构。

Typically your solution would look like this:通常,您的解决方案如下所示:

YourProject.Model (Class Library with POCO's - domain objects) YourProject.Model (带有 POCO 的类库 - 域对象)

YourProject.Repository (Class Library with Entity Framework). YourProject.Repository (带有实体框架的类库)。

YourProject.Services (Class Library acts as mediator between Repository and Controllers) YourProject.Services (类库充当存储库和控制器之间的中介)

YourProject.MVC (MVC2 Web Application) YourProject.MVC (MVC2 Web 应用程序)

YourProject.Tests (Unit Test Project - typically 1 project per tier) YourProject.Tests (单元测试项目 - 通常YourProject.Tests 1 个项目)

To answer your questions, the Repository abstracts the data from the other modules, the presentation layer is MVC2, and the application layer could be built into the Services module, or have another module altogether.为了回答您的问题,Repository 将数据从其他模块中抽象出来,表示层是 MVC2,应用层可以内置到 Services 模块中,也可以包含另一个模块。

Of course MVC fits beautifully with TDD, you can mock your controllers and test the class library just like you would test any class library.当然,MVC 非常适合 TDD,您可以模拟控制器并测试类库,就像测试任何类库一样。

Check out Rob Conery's MVC Storefront series on www.asp.net - best video series ive ever seen.在 www.asp.net 上查看 Rob Conery 的 MVC Storefront 系列 - 我见过的最好的视频系列。

Good luck!祝你好运!

您应该在 ASP.NET MVC 网站上查看带有八节教程的 ContactManager 示例,它是使用存储库类实现的,因此数据层是抽象的。

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

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