我可以访问从presentation层的库? [英] Can I access a repository from presentation layer?

查看:120
本文介绍了我可以访问从presentation层的库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始与DDD。我与参与DDD应用程序中的数层之间的互动有点糊涂。

I am starting with DDD. I am a bit confused with the interaction between the several layers involved in a DDD application.

我可以打电话给我的资料库从我的presentation层?如果不是我必须复制在我的服务层的存储库(这ofcourse将依次使用这些函数库)提供的CRUD功能?什么是做到这一点的最好方法是什么?

Can I call my repositories from my presentation layer? If not do I have to replicate the CRUD functionality provided by the repositories in my service layer (which ofcourse will in turn use the repository for these functions)? What would be the best way to do this?

推荐答案

究竟你presentation层是什么意思?
如果你指的是控制器/ presenter,那么它是完美的罚款。我已经使用的经验法则是,如果控制器动作是4行code或更多我应该看看重构到一个应用服务类,但仍 - 无论是在应用层面,你当然可以使用资料库有

What exactly do you mean by presentation layer? If you mean the Controller/Presenter, then it's perfectly fine. The rule of thumb that I've used is if the controller action is 4 lines of code or more I should look at refactoring to an application service class but still - both are at the application level and you can certainly use repositories there.

您措辞你的问题的方式 - 我当然可以misinter preting这一点 - 听起来很像你想从你的观点或codebehind引用资源库。在这种情况下,我会说不!没有!不!

The way you phrased your question - and I could certainly be misinterpreting this - sounded suspiciously like you were thinking of referencing the repository from your view or codebehind. In that case I would say no! no! no!

这篇关于我可以访问从presentation层的库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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