最佳答案
我使用自动映射器来映射多个对象(db 类到 ui 对象)。
地图1:
Mapper.CreateMap<sourceone, destination>().ForMember(sss => sss.one, m => m.MapFrom(source => source.abc));
地图2:
Mapper.CreateMap<sourcetwo, destination>().ForMember(sss => sss.two, m => m.MapFrom(source => source.xyz));
destination d = new destination();
//地图1
d = AutoMapper.Mapper.Map<sourceone, destination>(sourceone);
//地图2
d = AutoMapper.Mapper.Map<sourcetwo, destination>(sourcetwo);
Once I make call to the 'Map 2', the values that are populated using Map 1 are lost.. (i.e destination.one is becoming empty). How do I fix this?