Asp.net-Mvc
AutoMapper.Mapper 不包含 CreateMap 的定義
這可能是一個基本問題,但想知道我沒有得到 AutoMapper.Mapper.CreateMap 方法。
我是否使用了錯誤的 AutoMapper 參考/包?謝謝
該
CreateMap方法的靜態版本在 4.2 中已棄用,然後在 5.0 版中從 API 中刪除。Jimmy Bogard 在這篇博文中更詳細地討論了這一點。映射的新技術是非靜態的,就像這樣(程式碼來自文章):
var config = new MapperConfiguration(cfg => { cfg.CreateMap<Source, Dest>(); }); IMapper mapper = config.CreateMapper(); var source = new Source(); var dest = mapper.Map<Source, Dest>(source);
