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>()