是否有可能对应多个对象DTO使用Automapper单一视图模型?

问题描述:

我不知道是否有可能对应多个对象DTO使用Automapper单一视图模型对象?

I was wondering if it is possible to map multiple DTO objects to a single ViewModel object using Automapper?

从本质上讲,我有多个DTO对象和想显示ASP.NET MVC 2.0在一个屏幕上每个信息。要做到这一点,我想扁平化DTO对象(或其中的部分...)到视图模型和视图模型表示传递给视图。如果我有一个DTO,这将是很容易,但我从来没有见过它正与多个完成。显然,有一些迂回的方式来做到这一点(外automapper的),但是这是我想借此如果可能的办法。

Essentially, I have multiple DTO objects and would like to display information from each on a single screen in ASP.NET MVC 2.0. To do so I would like to flatten the DTO objects (or parts of them...) into the Viewmodel and pass said viewmodel to the view. If I had one DTO this would be easy, but I've never seen it being done with multiple. Obviously there are a number of roundabout ways to do this (outside of automapper), but this is the approach that I would like to take if possible.

您可以创建一个复合DTO持有两个或更多的DTO对象和复合DTO映射到输出视图模式。

You could create a composite DTO that holds two or more DTO objects and map the composite DTO to the output view model.