C# AutoMapper.Mapper.CreateMap已过时

C# AutoMapper.Mapper.CreateMap已过时,c#,automapper,asp.net-mvc-5,C#,Automapper,Asp.net Mvc 5,当我读到《ASP_NET-MVC-5-with-Bootstrap-and-Knockout_js》这本书时,我无法编译这些失败的代码 AutoMapper.Mapper.CreateMap(_sourceType, _destinationType); 如果根据新版本指南修改它Mapper.Initialize(cfg=>cfg.CreateMap()),则会出现以下错误:严重性代码描述项目文件行抑制状态 错误CS0246找不到类型或命名空间名称“\u sourceType”(是否缺少usi

当我读到《ASP_NET-MVC-5-with-Bootstrap-and-Knockout_js》这本书时,我无法编译这些失败的代码

AutoMapper.Mapper.CreateMap(_sourceType, _destinationType);
如果根据新版本指南修改它Mapper.Initialize(cfg=>cfg.CreateMap()),则会出现以下错误:严重性代码描述项目文件行抑制状态 错误CS0246找不到类型或命名空间名称“\u sourceType”(是否缺少using指令或程序集引用?) 有人能帮我提些建议吗

namespace BootstrapIntroduction.Filters {
    [AttributeUsage(AttributeTargets.Method)] 
    public class GenerateResultListFilterAttribute : FilterAttribute, IResultFilter {
        private readonly Type _sourceType;   
        private readonly Type _destinationType;

        public GenerateResultListFilterAttribute(Type sourceType, Type destinationType) {
            _sourceType = sourceType;
            _destinationType = destinationType;
        }

        public void OnResultExecuting(ResultExecutingContext filterContext) {
            var model = filterContext.Controller.ViewData.Model;

            var resultListGenericType = typeof(ResultList<>).MakeGenericType(new Type[] { _destinationType });
            var srcGenericType = typeof(List<>).MakeGenericType(new Type[] { _sourceType });
            var destGenericType = typeof(List<>).MakeGenericType(new Type[] { _destinationType }); 

            AutoMapper.Mapper.CreateMap(_sourceType, _destinationType);
            var viewModel = AutoMapper.Mapper.Map(model, srcGenericType, destGenericType);

            var queryOptions = filterContext.Controller.ViewData.ContainsKey("QueryOptions") ? 
                      filterContext.Controller.ViewData["QueryOptions"] : new QueryOptions();

            var resultList = Activator.CreateInstance(resultListGenericType, viewModel, queryOptions);

            filterContext.Controller.ViewData.Model = resultList;  
        }

        public void OnResultExecuted(ResultExecutedContext filterContext) {
        }  
    }
namespace BootstrapIntroduction.Filters{
[AttributeUsage(AttributeTargets.Method)]
公共类GenerateResultListFilterAttribute:FilterAttribute,IResultFilter{
私有只读类型_sourceType;
私有只读类型_destinationType;
public GenerateResultListFilterAttribute(类型sourceType,类型destinationType){
_sourceType=sourceType;
_destinationType=destinationType;
}
ResultExecuting(ResultExecutingContext filterContext)上的公共无效{
var模型=filterContext.Controller.ViewData.model;
var resultListGenericType=typeof(ResultList).MakeGenericType(新类型[]{u destinationType});
var srcGenericType=typeof(List).MakeGenericType(新类型[]{u sourceType});
var destGenericType=typeof(List).MakeGenericType(新类型[]{u destinationType});
AutoMapper.Mapper.CreateMap(_sourceType,_destinationType);
var viewModel=AutoMapper.Mapper.Map(model,srcGenericType,destGenericType);
var queryOptions=filterContext.Controller.ViewData.ContainsKey(“queryOptions”)?
filterContext.Controller.ViewData[“QueryOptions”]:新建QueryOptions();
var resultList=Activator.CreateInstance(resultListGenericType、viewModel、queryOptions);
filterContext.Controller.ViewData.Model=resultList;
}
ResultExecuted上的公共无效(ResultExecutedContext筛选器上下文){
}  
}

我发现有人也有同样的问题,但没有答案:

找到书中使用的automapper版本,并使用准确的版本。如果无法编译,请包括编译错误。我知道automapper Initialize的可能副本在新版本中已更改,但这个问题可能没有什么不同,因为我们已经生成了ic问题同时,我搜索url(),但仍不知道如何操作。找到书中使用的automapper版本,并使用准确的版本。如果无法编译,请包括编译错误可能重复的“我知道automapper Initialize”已在新版本中更改,但此问题可能会有点不同,因为同时有一般问题,我搜索了url(),但仍然不知道如何做。