English 中文(简体)
Linq 至Q层/层
原标题:Linq to SQL layers/architecture?

I am sorry for my question may looking a old repetitive questions but I as I am starting Linq to SQL I want to discuss how many layers (architecture) should I use ?

我主要在网站和中小型网络应用上工作。 我理解将应用分成几层,有助于维持和加强这一系统,但坦率地说,我想要某种平衡方法,使我能够迅速发展,并使法典重新使用。 我不能用这么多时间对各层进行不必要的管理。

在我使用4层之前(商业物体、BLL、DAL和用户界面)。 由于不同的人描述了不同的层次,我对此感到困惑。 请指导我,我应该使用什么和多少层? 增 编

最佳回答

我决定为小型项目使用一层(DAL + BL),大型应用将使用DAL &的不同层; BLL。 我将使用Linq在DAL,而I Queryable将返回。

问题回答

不使用层结构。 Use the onion structure

从结构角度看,最重要的方面是分开关注。 各种关切的分离导致清洁法、轻松的维护、可伸张等。 尽管如此,我建议根据以下标准作出决定:

  • Try to architect your system in a loosely coupled way. Use messaging instead of RPC as messaging is reliable, scalable, asychronous, loosely coupled, etc. You can either use MSMQ or NServiceBus (for service bus based architecture).
  • Create layers based on the separation of concerns concept. For e.g. you can go for typical 3 layered architecture which will have just UI layer, business logic layer (business rules+workflow) and data access layer or more granular such as UI layer, services layer (facade), business logic layer, data access layer, etc. Using IoC / Dependency injection will make life easy as none of the layers will have direct dependency. Moreover, it promotes unit testing easy as you inject mocks instead of the real implementations for the unit test. There are so many IoC frameworks available (NInject, Autofac, Castle Windsor, Structure Map, etc...)
  • Try to use EF instead of Linq to SQL as the later works only with SQL, while the EF works with any database. Moreover, in my opinion, EF is where microsoft is innovating and I would assume that Linq to SQL may be retired one day.

大问题 这是我在建造中小地点时经常遇到的问题。 我认为,在我们所有工作中,我们都需要努力找到这种平衡,即建立一个能够给你带来最大灵活性并能够迅速部署的结构。

在谈到这一点时,我发现,利用,对LINQ项目有很大帮助。 我与Model View Presenter 模式(关于网络森林产品或其他项目),为使用最小层的再利用提供了巨大基础。

我的“网络”叫上一个讲演员班,这反过来又负责提出看法。 提出这种观点的人可以把N号储存库称作“。 托存处是您的“数据目录”类别和“准则Q”电话。 这些话重回了模式班。

无论用量大小,这种巨大好处是,从你手中重新大量使用。 托存、您能够最大限度地使用准则,并且你使用了其他软件开发商容易阅读和支持的一些模式。

Another big benefit is that you now have created a simple architecture that can benefit from using Unit Testing to test from the Presenter back to the Repository without a ton of effort.

亲爱!





相关问题
SQL Server - How many users do I *really* need?

I m setting up an application, and I m looking into purchasing a license for SQL Server. My question is pretty simple (though may have a complicated answer...) How many users accounts do I really ...

Object Graph / Persistence Question

I m currently working with an online application that requires multiple screens/steps in order to complete. The application domain is modeled using an object graph. Persistence to and from a database ...

Why does stack get truncated in Exception.StackTrace?

Why does the high part of the stack (in Exception.StackTrace) gets truncated? Let s see a simple example: public void ExternalMethod() { InternalMethod(); } public void InternalMethod() { try ...

ASP.NET MVC and Service Oriented Architecture

I would like to know how do i incorporate a feature like wcf within and MVC application. My current idea of the architecture is as follows: EntityFramework -> ASP.NET MVC (Views) ...

热门标签