我需要在MVC架构一些澄清和三层体系结构 [英] I need some clarification on the MVC architecture and the three-tier architecture

查看:220
本文介绍了我需要在MVC架构一些澄清和三层体系结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在读的书临ASP NET MVC框架和我得到了很多的事情真的很困惑。我一直在试图做一些研究,但我发现有这么多不同的方法和概念,我被抛出,它只是使事情变得更糟
所以,我有几个问题:


  1. 我知道MVC是应该的功能分为三个主要的事情:型号 - >控制器 - >查看。是MVC比三层架构不同的方法?或者我还是应该思考在我的项目创建数据访问层和业务逻辑层的?


  2. 究竟是什么库?这就是我的数据访问层的作用?在哪里/如何库融入了MVC?


  3. 有关使用LINQ到SQL与数据库进行交互,但尚未它说的LINQ to SQL不会在未来的支持,而微软正在放弃它的实体框架书中会谈。哪里实体框架装进MVC和我如何与它进行交互?


在此先感谢您的帮助!

马特


解决方案

  1. MVC是大多为presentation层的图案,并且它的重点是视图和控制器之间的相互作用。该模型可以被认为是组件那是负责维护状态,包括持久性应用程序。

    在一个简单的应用程序模型可能仅仅是一个LINQ到SQL模型。在大型企业应用的模型可能包含一个数据访问层,业务层和域层。在ASP.NET MVC不限制你到M应该如何实现。


  2. 借助模式,是落实M的持久性部分的一种方式该 ActiveRecord的是另一回事。它的模式选择依赖于应用程序的复杂程度以及preferences。

    看看的的NerdDinner教程的步骤3 在那里创建一个简单的存储库使用LINQ to SQL。


  3. LINQ to SQL的不会死人。微软仍然会提高核心并添加客户要求的地方是有道理的,但实体框架将是主要焦点。看看这个职位 LINQ到SQL更改在.NET 4.0中

    可以使用的EF是一种方式,LINQ到SQL相似,但它也更灵活,因此它可以以其他方式被使用。例如EF4将更多或更领域驱动设计您自己的POCO对象的支持较少的持久性。


I've been reading the book Pro ASP NET MVC Framework and I'm getting really confused with a lot of things. I've been trying to do some research but I'm finding that with so many different approaches and concepts being thrown at me, it's just making things worse.
So I have a few questions:

  1. I know MVC is supposed to split the functionality into three main things: Model -> Controller -> View. Is the MVC a different approach than the three-tier architecture? Or am I still supposed to be thinking of creating a Data Access Layer and a Business Logic Layer in my project?

  2. What exactly are Repositories? It is what acts as my Data Access Layer? Where/How do Repositories fit into the MVC?

  3. The book talks about using LINQ to SQL to interact with the database but yet it states that LINQ to SQL will not be supported in the future and that Microsoft is dropping it for the Entity Framework. Where does the Entity Framework fit into the MVC and how do I interact with it?

Thanks in advance for your help!
Matt

解决方案

  1. MVC is mostly a pattern for the presentation layer, and it focuses on the interaction between the view and the controller. The model can be considered to be the components of the application that are responsible for maintaining state, including persistence.

    In a simple application the model might just be an LINQ-To-SQL model. In a large enterprise application the model might contain a data access layer, business layer, and a domain layer. The ASP.NET MVC does not restrict you to how the M should be implemented.

  2. The Repository pattern is one way to implement the persistence part of the M. The ActiveRecord is another. Which pattern to choose depends on the complexity of the application, and your preferences.

    Take a look at Step 3 of the NerdDinner tutorial where they create a simple repository using Linq to SQL.

  3. Linq to SQL will not be dead. Microsoft will still improve the core and add customer requests where it makes sense but Entity Framework would be the primary focus. Take a look at this post for LINQ to SQL changes in .NET 4.0.

    The EF can be used is a similar way as LINQ to SQL, but it is also more flexible so it can be used in other ways. For example EF4 will more or less support persistence of your own POCO objects in a more Domain Driven Design.

这篇关于我需要在MVC架构一些澄清和三层体系结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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