ASP.NET MVC(域模型库,流利,服务 - 为我的项目结构) [英] ASP.NET MVC (Domain Model, Repository, Fluent, Services - Structure for my Project)

查看:199
本文介绍了ASP.NET MVC(域模型库,流利,服务 - 为我的项目结构)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的ASP.NET MVC Web应用程序,我有:

In my ASP.NET MVC web application, I have:

  • 域模型,通过的LINQ to SQL创建

  • Domain Model, created by LINQ to SQL

仓库了,如

UserRepository OrderRepository

IQueryable的Fluents为IQueryable的扩展方法,如

IQueryable Fluents as IQueryable Extension Methods such as

公开的IQueryable<令> GetNewOrders(这IQueryable的<令>)

服务,如

UserService的 OrderService的

实用工具类和扩展方法,如

Utility Classes and Extension Methods such as

CryptoUtility (做散列等),字符串等扩展

CryptoUtility (doing Hashing etc.) and String etc. extensions

的ViewModels这是特别为每个MVC视图

ViewModels which are special for each MVC View

在ASP.NET MVC项目本身(控制器,查看)

The ASP.NET MVC project itself (Controllers, Views)

我在寻找最好的项目结构/组织我的情况,尤其是分离成不同的组件以及如何的依赖应该像这些层之间。 Web资源遗憾的是走不进好的详细介绍这一点。

I'm looking for the best project structure/organization for my case, especially separating into different assemblies and how dependencies should look like between these layers. Web resources unfortunately don't go into good detail about this.

一个提示:目前资源库,服务,IQueryable的Fluents等直接对着干的领域模型实现,我没有为他们的接口定义。我认为没有必要,但也许这是需要松耦合?我的服务有一个接口(例如IOrderService),和我的仓库实施IRepository< T>

One hint: Currently Repository, Services, IQueryable Fluents etc. work directly against domain model implementation, I don't have an interface definition for them. I considered it unnecessary but maybe this is needed for loose coupling? My Services have an interface (e.g. IOrderService), and my repositories implement IRepository<T>.

鸭preciate你在一个简洁的方式组织这次投入,特别是要依靠什么和放哪一层;装配组织。谢谢!

Appreciate your input on organizing this in a concise manner, and especially what layer should depend on what & assembly organization. Thank you!

推荐答案

我想看看在洋葱架构的此处。这个基本架构可以很好的任何项目,将让你的核心工程(领域层,持久性等),从你的web项目中分离出来。

I would look at the article by Jeffrey Palermo on the Onion Architecture here. This basic architecture works well in any project and will allow you to separate your core project (domain layer, persistence, etc.) from your web project.

我们使用与MVC / StructureMap / FluentNHibernate并已经取得了巨大的成功。

We use this with MVC/StructureMap/FluentNHibernate and have had great success.

我们最终不得不类似如下的结构。

We end up having a structure similar to the one below.

> trunk
  + build (build scripts)
  + lib (external libraries)
  > src (source code)    
   >> Organization.App (solution name)
     >> Organization.App.Core (code library)
        + Config
        > Domain
          > Model
          > Persistence
          > Queries
          > Services
        > Persistence
        > Services
     >> Organization.App.Web (mvc web app)
        > Assets
          + Images
          + Scripts
          + Stylesheets
        + Controllers
        + Views
        + ViewModels

这是基本的思路。 Web应用程序引用的核心应用程序域实体工作的我们的代码库/股。请查看这个旧的项目对谷歌code 一个类似的例子。关于这个伟大的部分是,我们已经能够添加新的UI的项目类型相同的解决方案,并重新利用我们的核心项目按预期。就像一个控制台应用程序或第二web应用程序,或任何你需要的。

That's the basic idea. The web app references the core app for domain entities our repository/unit of work. Check out this older project on google code for a similar example. The great part about this is we have been able to add new "UI" project types to the same solution and re-use our core project as intended. Like a console app or a second web app, or whatever you need.

这篇关于ASP.NET MVC(域模型库,流利,服务 - 为我的项目结构)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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