I have two objects, which are basically (so not entirely!) the same. They both have properties with values.
I’d like to map one object to the other and overwrite all the property values of the from the source target to the destination target. But it seems that this isn’t happening by default?
NOTE:
My maps are already defined at the startup of my application.
My objects basically looks like this:
public class Object1
{
public String Name = "My new Name";
}
public class Object2
{
public String Name = "My old Name";
}
// Then somewhere in my code:
Mapper.Map(obj1, obj2);
So i try to map all the values from Object1, to Object2. But when the mapping is done, then Object2 still has its old value, instead of the value from Object1.
How can i map the values in AutoMapper?
Update
Automapperreturns new instance, assign that return instance to the old one.