DDD - DAL 是否访问域层 [英] DDD - Does DAL access Domain Layer

查看:39
本文介绍了DDD - DAL 是否访问域层的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到一些示例引用了来自 DAL 的域层.我看到存储库接口是在域层中定义的,并且由于 DAL 实现了它们,因此它们需要引用域层.DAL 还需要知道要返回的实体,以便上游引用.我以为我们只提到下游",有人能解释一下吗?

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?

推荐答案

是的,没关系.

这样想:

如果您要更改(替换)任何图层,它将是哪个图层?您不太可能更改域层,因为这会更改您的整个应用程序.如果更改 DAL,则不需要修改域层.

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.

因此,您的域不依赖于任何东西是一件好事.您的 DAL 可以依赖于您的域,因为您的域是应用程序的核心.

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/

这篇关于DDD - DAL 是否访问域层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆