这个问题是由于在最新版本的Automapper中,GetAllTypeMaps方法已被移除所致。下面是如何解决这个问题的示例代码:
使用Map方法映射对象时,可以使用new对象创建新实例,进行操作:
var source = new SourceObject(); var destination = new DestinationObject();
Mapper.Map(source, destination);
或者使用CreateMap方法在映射之前进行配置:
Mapper.Initialize(cfg => {
// Add your AutoMapper configuration here...
cfg.CreateMap
var source = new SourceObject();
var destination = Mapper.Map
这些代码都不需要使用GetAllTypeMaps方法,而是直接创建映射或进行配置。