문제

In a DDD project, I have this structure:

Infrastructure

  • MyProj.Library (contains helper methods)
  • MyProj.Factory (contains methods for IoC and DI)
  • MyProj.Data (contains an implementation of IUserRepository)

Domain

  • MyProj.Domain (contains the domain aggregates and repository interfaces, i.e. IUserRepository)

Application

  • MyProj.WebAPI

I need to know if MyProj.Data belongs to the Infrastructure layer or Domain layer. I am really confused where the implemented repositories belongs.

도움이 되었습니까?

해결책

Typically you would have the repository implementation in the infrastructure layer and the repository interfaces in the domain layer.

As an example, have a look at the Onion Architecture which states

Inner layers define interfaces. Outer layers implement interfaces

Onion Architecture

In this simple implementation of the Onion Architecture, the VisitorRepository is residing in the Infrastructure layer and implements IVisitorRepository found in the Core (Domain) layer.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top