问题描述
有谁知道一个良好的(阅读:快速code)方法转换的DTO查看模型或映射DTO成员视图模型成员?最近我一直在寻找自己写很多转换和辅助方法,但是这是一个非常艰巨而繁琐的任务。此外,它通常会需要做两次(DTO - >视图模型,视图模型 - > DTO)。
Does anyone know of a good (read: quick to code) method for converting DTOs to View Models or mapping DTO members to View Model members? Lately I've been finding myself writing many conversion and helper methods but this is a very arduous and tedious task. Moreover, it will often needs to be done twice (DTO -> View Model, View Model -> DTO).
有没有一种方法,技术或技术,它可以让我快速,高效地做到这一点吗?
Is there a methodology, technique, or technology which would allow me to do this more quickly and efficiently?
推荐答案
看一看 Automapper 。它是一个开源项目,涉及正是你所遇到的问题。
Have a look at Automapper. It is an open source project that addresses exactly the problem you are having.
这篇关于转换的DTO查看模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!