开发者

ASP.NET MVC Architecture - Generic repository pattern

开发者 https://www.devze.com 2023-02-22 00:45 出处:网络
I\'m new to ASP.NET MVC and I\'m trying to figure out the right way of coding in it. I\'m trying to implement a multi-layer architecture with a generic repository for data access.

I'm new to ASP.NET MVC and I'm trying to figure out the right way of coding in it.

I'm trying to implement a multi-layer architecture with a generic repository for data access.

Here's what I was used to do in Webforms solutions (each item is a separate project):

  • MyProject.Data (Entity Framework .Edmx + Generic Repository)
  • MyProject.Business.Services (Calls repository, applies business rules, etc)开发者_开发问答
  • MyProject.Business.DomainModel (Entities)
  • MyProject.UI (ASP.NET Webforms app)

Now in an MVC pattern:

I think I should define my ViewModels in MyProject.Business.DomainModel and my Models in MyProject.Business.Services. And Data layer remains unchanged. In summary:

  • MyProject.Data (Entity Framework .Edmx + Generic Repository)
  • MyProject.Business.Services (Models implementation)
  • MyProject.Business.DomainModel (POCO Entities + ViewModels)
  • MyProject.UI (ASP.NET MVC app)

I'll appreciate your comments about this approach.


Check out the onion architecture. http://jeffreypalermo.com/blog/the-onion-architecture-part-1/

Codecampserver is an implementation example. http://codecampserver.codeplex.com/

SharpArchitecture is another example to look at. http://code.google.com/p/sharp-architecture/

They dont do things exactly the same but they do separate concerns.

0

精彩评论

暂无评论...
验证码 换一张
取 消