且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Automapper:更新属性值,而无需创建一个新的对象

更新时间:2023-12-03 21:23:10

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

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.