Automapper: Update property values without creating a new object

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


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.


To make this work you have to CreateMap for types of source and destination even they are same type. That means if you want to Mapper.Map<User, User>(user1, user2); You need to create map like this Mapper.Create<User, User>()

链接地址: http://www.djcxy.com/p/6372.html

上一篇: 使用AutoMapper合并两个对象以产生第三个对象

下一篇: Automapper:更新属性值而不创建新对象