是否有可能对应多个对象DTO使用Automapper单一视图模型? [英] Is it possible to map multiple DTO objects to a single ViewModel using Automapper?

查看:658
本文介绍了是否有可能对应多个对象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.

这篇关于是否有可能对应多个对象DTO使用Automapper单一视图模型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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