DDD - Does DAL access Domain Layer

◇◆丶佛笑我妖孽 提交于 2019-12-24 07:27:51

问题


I see some samples referencing the Domain Layer from DAL. I see that the repository interfaces are defined in the Domain Layer and since the DAL implements them, they need to reference the Domain Layer. The DAL also needs to know the Entities to return so the reference upstream. I thought that we only reference "downstream", can someone explain?


回答1:


Yes, that's OK.

Think about it like this:

If you are going to change (replace) any layer, what layer will it be? It's highly unlikely that you'd change your domain layer, since that would change your entire application. If you change the DAL, then you shouldn't need to modify the domain layer.

So, it's a good thing that your domain does not depend on anything. Your DAL can depend on your domain since your domain is the meat of your application.

I have written an article about this which explains this in more detail:

http://www.kenneth-truyers.net/2013/05/12/the-n-layer-myth-and-basic-dependency-injection/




回答2:


The Domain is located downstream.

See Onion Architecture



来源:https://stackoverflow.com/questions/24232068/ddd-does-dal-access-domain-layer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!