Mapper不包含CreateMap的定义

Mapper不包含CreateMap的定义

本文介绍了AutoMapper.Mapper不包含CreateMap的定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是一个基本问题,但想知道我没有得到AutoMapper.Mapper.CreateMap方法.

This might be a basic question but wondering I am not getting AutoMapper.Mapper.CreateMap method.

我使用了错误的AutoMapper参考/软件包吗?谢谢

Am I using wrong AutoMapper reference/package? Thanks

推荐答案

在4.2中弃用了CreateMap方法的静态版本,然后在5.0版中将其从API中删除.吉米·鲍嘉(Jimmy Bogard)在这博客文章.

The static version of the CreateMap method was deprecated in 4.2, then removed from the API in version 5.0. Jimmy Bogard talks about this in more detail in this blog post.

这种新的映射技术是非静态的,就像这样(代码来自帖子):

The new technique for mapping is non-static, like this (code is from the post):

var config = new MapperConfiguration(cfg => {
    cfg.CreateMap<Source, Dest>();
});

IMapper mapper = config.CreateMapper();
var source = new Source();
var dest = mapper.Map<Source, Dest>(source);

这篇关于AutoMapper.Mapper不包含CreateMap的定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 07:48