哪里DTOS为InputModel /视图模型适合于分层Archicture [英] Where does DTOS as InputModel / ViewModel Fit in Layered Archicture

查看:173
本文介绍了哪里DTOS为InputModel /视图模型适合于分层Archicture的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道哪里InputModel和的ViewModels适合在4层建筑。

I'm trying to understand where does InputModel and ViewModels fit at the 4 Layer Architecture.

presentation |应用|域名|基建

Presentation | Application | Domain | Infrastructure

由于应用层约需beteween presentation层和领域层进行数据交换照顾,我推测,他们必须住这层内,以及适配器将其转换回域实体,反之亦然。

Given that the Application Layer takes care about exchange data beteween Presentation Layer and Domain Layer, I supposed that, they must live inside this layer, as well the adapter to convert It back to Domain Entity and vice versa.

InputModels,也称为命令,在ASP.NET MVC中,他们可以用的ViewModels一致。

InputModels, also know as Commands, in ASP.NET MVC they can coincide with ViewModels.

是没有意义的,我的ViewModels的presentation内。从应用层我应该返回的ViewModels到presentation和接收的ViewModels到马普回域实体。如果我有presentation内的ViewModels和presentations指的是应用层,我将有一个循环引用。

Makes no sense to me ViewModels inside the Presentation. From the Application Layer I should return ViewModels to the Presentation and receive ViewModels to Mapp It back to Domain Entity. If I have ViewModels inside the Presentation, and the presentations refers to Application Layer, I will have a loop reference.

和也,例如,如果我有一个presentation打造成为ASP.NET MVC和我有必要改变它的Windows应用程序,我将失去这个的ViewModels适合我的必需品,什么是耻辱,因为我已经拥有了一切内置于改变presentation技术。

And also, for example, If I have a Presentation build into ASP.NET MVC and I have the necessity to change It for Windows Application I will lost this ViewModels that fit on my requisites, what is a shame, given that I already have everything built in to change the presentation Technology.

我在读这本书从恐龙埃斯波西托和Andrea Saltarello,微软.NET:构建适用于企业。他们没有过多谈论应用层,只能说,这应该协调域服务和仓库来fullfill的用户案例,并从presentation隐藏域。

I'm reading the book From Dino Esposito and Andrea Saltarello, Microsoft .NET: Architecting for the Enterprise. They don't talk too much about the Application Layer, only say that, this one should Orchestrate Domain Services and Repositories to fullfill User Cases, and to hide Domain from the Presentation.

在这里输入的形象描述

这是正确的?我应该把这个DTO的应用层里面呢?如果没有,在哪里他们适合在Lasangna?

Is this right? Should I put this DTOs inside the Application Layer? If not, Where does they fit on the Lasangna?

推荐答案

的DTO应定义在任何两层是在依赖食物链更高,以避免循环引用。这将意味着在一个洋葱 /六角形结构的应用层,因为依赖性向内点 - presentation参考应用。我不知道其他分层的体系结构样式。或者,你可以把DTO的,其中将由其他两个引用自己单独的层,站在上面他们。

DTOs should be defined in whichever of the two layers is higher in the dependency food chain, to avoid circular references. This would mean the Application layer in an Onion / hexagonal architecture, because dependencies point inward -- Presentation references Application. I don't know about other layered architecture styles. Alternatively, you could place DTO's in their own separate layer which would be referenced by the two others and stand above them.

这篇关于哪里DTOS为InputModel /视图模型适合于分层Archicture的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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