문제

Help to understand deeper, there are contract / interface for repository

public interface ICoolRepository
{
    Entity GetById(int id);
}

where shoul it be declared in domain, infrastracture or app module?

Can repository interface be used in entities like that:

public class User
{
...
  public DoStuff(ICoolRepository repo)
  {
    //here goes using cool repository
  }
...
}

where can it be used with no problem? please, give reasones for that

도움이 되었습니까?

해결책

The interface should be defined in Domain Model, as it is a part of Ubiquitous Language (it expresses, what is an aggregate and what is not, it expresses the ways the aggregates should be looked for which relates directly or indirectly to some use cases). The implementation of the repository should go to Infrastructure as it contains DAL/ORM references.

It is rather uncommon or wrong to use a repository in entities, but your question is too generic to give you any meaningful answer.

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