ASP.NET MVC 3 架构方向
我正在将一个经典的 ASP 网站转换为 .NET。该应用程序已经有一个后端数据库,其中包含用于与数据库通信的存储过程。我想在这个项目中使用 MVC3 和 EF。
我的问题是,在这种环境下工作的一个很好的适度例子在哪里?
我了解模型视图控制器模式如何在基本示例上工作。我浏览了 MVC Music Store 演示并部署了它。但是,我正在努力解决某些代码的放置位置。
我正在寻找有关如何使用存储过程将现有数据库与 EF 结合起来的示例以及模型的外观。我也在寻找在哪里放置传统上对象方法的代码。
如果我有一个联系人模型,那么代码在哪里与该联系人交互?我不是在谈论带回您想要推送到视图的数据的代码。这就是存储库的用武之地吗?如果是这样,哪里有关于使用存储库的好教程?
我很感激你的帮助。我意识到这是一堆问题的集合,但我也不认为我是唯一一个为此苦苦挣扎的人。
I am converting a classic ASP website to .NET. The application already has a back-end database with stored procedures for communicating with the DB. I want to use MVC3 and EF for this project.
My question is where is a good moderate example of these working in this environment?
I understand how the Model View Controller pattern works on basic examples. I went through the MVC Music Store demo and deployed it. However, I'm struggling with where I put certain code.
I'm looking for examples of how to tie into the existing DB with EF using the stored procedures and how the models should look. I'm also looking for where do I put code which is traditionally object methods.
If I have a Contact model, where does the code go to interact with that contact? And I'm not talking about the code that brings back the data you want to push to the View. Is that where Repositories come in? If so, where is a good tutorial on using repositories?
I appreciate the help. I realize this is a bunch of questions in one, but I don't think I'm the only one struggling with this either.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我确信有很多可用的教程可以帮助您入门。 “书呆子晚餐”示例帮助我入门,因为它很好地解释了存储库模式以及如何分离项目。您可以在此处找到当前项目:http://nerddinner.codeplex.com/
I'm sure there are plenty of tutorials available, which should help you get started. The 'Nerd dinner' example helped me getting started, as it gave good explanations of the repository pattern, and how to separate the project. You can find the current project here: http://nerddinner.codeplex.com/
我肯定会将 DAL 放在一个单独的项目中,并且肯定会在应用程序的数据访问层和业务逻辑层之间创建一个抽象层。
存储库和工作单元模式非常适合此目的。
你可以看看下面的文章。它们非常适合开始创建数据访问层:
为 ASP.NET MVC 应用程序创建实体框架数据模型
http://www.asp.net/entity-framework/tutorials/creating-an-entity-framework-data-model-for-an-asp-net-mvc-application
< strong>在 ASP.NET MVC 应用程序中实现存储库和工作单元模式
http://www.asp.net/entity-framework/tutorials/implementing-the-repository-and-unit-of-work-patterns-in-an-asp-net-mvc-application
这些内容来自 http://asp.net 上的使用 MVC 开始使用 EF 系列。您可以从左侧网站的导航面板找到更多有用的文章。
I would definitely put the
DAL
in a separate project and I would definitely create an abstraction layer between the data access layer and the business logic layer of my application.The Repository and Unit of Work Patterns are great for this purpose.
You can take a look at following articles. They are great for starting to create your data access layer :
Creating an Entity Framework Data Model for an ASP.NET MVC Application
http://www.asp.net/entity-framework/tutorials/creating-an-entity-framework-data-model-for-an-asp-net-mvc-application
Implementing the Repository and Unit of Work Patterns in an ASP.NET MVC Application
http://www.asp.net/entity-framework/tutorials/implementing-the-repository-and-unit-of-work-patterns-in-an-asp-net-mvc-application
These are from Getting Started with EF using MVC series on http://asp.net. You can find more useful articles there from the navigation panel on the left hand site there.
客户端复杂 Web 应用程序的一个很好的例子是 Microsoft 的 Project Silk。
它包含 MSDN 网站上的大量设计指南/文档以及一个带有完整源代码的示例应用程序,您可以下载和使用。
我建议您看一下它,特别是如果您要实现复杂的 UI(jQuery、jQuery UI、客户端渲染、AJAX)
A good example of a client-side complex web application is Project Silk from Microsoft.
It contains a lot of design guidelines / documentation on MSDN website and a sample app with full source code you can download and play with.
I would recommend taking a look at it, especially if you have a complex UI to implement (jQuery, jQuery UI, client-side rendering, AJAX)