Is there a way to keep the entire source object as a copy in my destination class as a property..
e.g.
Source:
class SourceClass
{
prop string Prop1 { get; set; }
prop string Prop2 { get; set; }
}
Destination:
class DestinationClass
{
prop string Prop1 { get; set; }
prop string Prop2 { get; set; }
prop SourceClass SourceClassCopy { get; set; }
}
and using automapper configuration something like
AutoMapper.Mapper.Initialize(cfg => {
cfg.ReplaceMemberName("this", "SourceClassCopy");
cfg.CreateMap<SourceClass, DestinationClass>(); //or .ForMember("SourceClassCopy", d => d.MapFrom(s => s));
});
Why I am doing this is coz I am having a hierarchical object and would like to keep a copy for reverse mapping as the Source class doesn't have a default constructor that will help me reverse map. Also the source class is in a library that I can't modify :( and has methods/functions that accept entire source object. Appreciate any help. Thanks.