Presentation <?> Domain <?> Persistenc

2019-04-12 23:38发布

问题:

Ok So I have a

  • PERSISTENCE layer, which grabs data from Entity Framework and puts it in some classes of its own, "Models", identical to the DB ones.
  • PRESENTATION layer, an MVC website
  • DOMAIN layer, which is a project independent to everything. Has some classes (Models) but not exactly as on the DB, has some business logic and so on.

How do I link these 3? (references)

回答1:

In a typical 3-tier Application architecture, you usually make your Data Access Layer (Data Persistence Layer if you will) reference your Domain Layer - You shouldn't add a reference from your Domain Model to your DAL, that'll create a circular dependency problem.

You then orchestrate the interaction between your Domain and Data Access Layers in your Presentation Layer (MVC App in your case).

In short:

  • Your DAL should reference your Domain Layer.
  • Your Presentation Layer should reference both your Domain Layer and DAL