I want to create a deep copy of an object. I chose to use the automapper because this way I dont have to edit classes and add there any extra code. Plus I use automapper for mapping my classes to DTOs.
On my surprise when I wanted to do a copy like:
var original = new TrainingSetDto()
var output = _mapper.Map<TrainingSetDto>(original);
the output
variable retrieved reference to the original
variable (shallow copy).
How to achieve my wanted result (deep copy of the original
) to get new instance with same properties ?
E.g. on this blog
https://jshowers.com/create-deep-copies-of-object-in-c-using-automapper/
was mentioned that static call Mapper.Map<Person>(originalPerson);
is the way how to do so. But these static methods are not there anymore.
Could you please point me to the right direction ?