ASP.NET MVC开发一个分层架构 [英] ASP.NET MVC Developing a Layered Architecture

查看:112
本文介绍了ASP.NET MVC开发一个分层架构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我新的ASP.NET MVC和截至目前我的MVC是如何工作的基本认识。我创建了一个简单的MVC的网站,只使用一个利用模式模型 - 视图 - 控制器项目。

但我想了解如何使一个使用特定的架构和有困难的时间寻找引用网上帮我理解它的MVC Web应用程序。

我得到了一个项目,研究,并改写它,但我不希望复制每个班一个一个不理解它是如何做的,我打算从头开始重写它,只是使用现有项目的指南。

I am new to ASP.NET MVC and as of right now I have the basic understanding of how MVC works. I have created a simple mvc website which uses only one project utilizing the pattern Model-View-Controller.
But I want to learn how to make an mvc web application that uses a specific architecture and having a hard time looking for references online to help me understand it.
I was given a project, to study, and rewrite it but I don't want to be copying each classes one by one without understanding how it's done, I plan to rewrite it from scratch and just use the existing project a guide.

我需要的恰恰是,如果有人能指出我哪里开始阅读理解这个项目的体系结构:

What I need exactly is if someone can point me to where to start reading to understand this project's architecture:

ProjectSolution
 Project.Web
  //An MVC web application

 Project.DataAccess
  //An edmx file (database first)
  Contracts
    IRepository.cs
    IUnitOfWork
  Repositories
    GenericRepository.cs
  UnitOfWork

 Project.Business
  Contracts
    IService1.cs
    IService2.cs
    ....so on
  Services
   Service1.cs
   Service2.cs
   ....so on

从仅仅依靠我个人的code阅读能力,我可以看到,这种设置,它由3个不同的项目,Project.Web是一个MVC Web应用程序,而另外2个是类库。

那么,在技术上,我知道这个架构是如何工作的,但我想知道如何从头做到最好的,我的意思是,这是自动生成的那些,哪些是分别写入等等等等,而且我也想学视图模型是如何工作的,因为里面Project.Web有一个文件夹的ViewModels的重新presents的是在视图中使用模型的集合。



Gahh!我迷路了,我不知道从哪里开始阅读。
我不需要每次解释,但你可以点我在哪里可以找到一个教程或类似的东西,这个项目我知道如何构建它。请帮忙!谢谢!

From just relying on my personal code reading capability, I can see that from this setup, it consists of 3 different projects, Project.Web is an MVC webapp, while the other 2 are Class Libraries.
Well, technically, I know how this architecture works, but I want to know how to make it from scratch, I mean, which ones are auto generated, which ones are written individually etc etc. And I also want to learn how ViewModel works, because inside Project.Web there is a folder ViewModels that represents a collection of models that is used in the view.

Gahh! I'm lost, I dont know where to start reading. I don't need explanation on each but can you point me where to find a tutorial or something similar to this project for me to know how to build it. Please help! Thank you!




注:我知道这是不是一个正确的问题被张贴在这里,但我绝望并寻求有经验的人帮助的地方点我



Note: I know this is not a proper question to be posted here but I am desperate and seeking help from the experienced ones to point me somewhere.

推荐答案

从您发布它看起来像解决方案(One解决方案)有三个不同的项目结构:

From the structure you posted it looks like the solution (One solution) has three different projects:


  • 1 Project.web :该网站项目本身在那里你会
    把所有的意见,CSS,脚本......在一个理想的实现
    MVC的(这取决于你是谁交谈)的网站项目
    应该完全没有逻辑,而且只有responsabilty应该是
    呈现信息给用户的。所以基本上在 V 的一部分
    MVC的。

  • 2 - Project.DataAccess :这是在 M ;该项目应
    管理该项目的所有数据部分,这包括:DAL,
    ORM,资料库,UOW ...

  • 3 Project.Business C 的一部分,所有的业务逻辑
    正在地方,基本上所有的类的做硬
    工作中,我认为它是CPU中。

  • 1- Project.web: That the website project itself where you will have all of your views, css, scripts ... in an "ideal implementation of MVC" (depending who are you talking to) the website project should have no logic at all and it's only responsabilty should be the render of the info to the user. so it's basically the V part of the MVC.
  • 2- Project.DataAccess: that's the M ; the project should manage all the data portion of the project and that includes: DAL, ORM, Repositories, UoW...
  • 3- Project.Business The C part, where all the business logic is taking place , where basically all of your classes doing the hard work , i think of it as the CPU.

您提到的2个项目是类库项目和Web是一个网站项目,这是一个架构我跟着来组织我的项目/解决方案。

You mentioned that the 2 projects are class library projects and the Web is a WebSite project and this is an architecture i follow to organize my projects/solution.

请注意,这是一个架构设计,组织项目,绝不是唯一或最好的之一。但与任何设计,你可以遵循尽量尊重的SOC(关注点分离)MVC模式的目的。

Please note that this is an architecture design to organize your projects and in no way is the only or best one. but with any design you might follow try to respect the SoC (Separation of Concerns) goal of the MVC pattern.

这篇关于ASP.NET MVC开发一个分层架构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆