Automapper:更新属性值,而无需创建一个新的对象 [英] Automapper: Update property values without creating a new object

查看:342
本文介绍了Automapper:更新属性值,而无需创建一个新的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何使用automapper更新另一个对象的属性值,而无需创建一个新的?

How can I use automapper to update the properties values of another object without creating a new one?

推荐答案

使用过载这需要现有的目标:

Use the overload that takes the existing destination:

Mapper.Map<Source, Destination>(source, destination);



是的,它会返回目标对象,但这只是一些模糊的其他情形。这是同一个对象。

Yes, it returns the destination object, but that's just for some other obscure scenarios. It's the same object.

这篇关于Automapper:更新属性值,而无需创建一个新的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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