title: AutoMapper.Mapper.CreateMap is obsolete
body: <p>When I read the book 'ASP_NET-MVC-5-with-Bootstrap-and-Knockout_js', the blew code can't be compiled</p>
  
  <pre><code>AutoMapper.Mapper.CreateMap(_sourceType, _destinationType);
  </code></pre>
  
  <p>If I modify it <strong>Mapper.Initialize(cfg => cfg.CreateMap&lt;_sourceType, _destinationType>())</strong>,according the new version guide,then got this error:Severity Code Description Project File Line Suppression State
  Error CS0246 The type or namespace name '_sourceType' could not be found (are you missing a using directive or an assembly reference?)
  Can anyone help me give some advice?</p>
  
  <pre><code>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&lt;&gt;).MakeGenericType(new Type[] { _destinationType });
              var srcGenericType = typeof(List&lt;&gt;).MakeGenericType(new Type[] { _sourceType });
              var destGenericType = typeof(List&lt;&gt;).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) {
          }  
      }
  </code></pre>
  
  <p>I found someone also had the same question but no answer:<a href="http://www.endyourif.com/integrating-automapper-with-an-mvc-result-filter/" rel="nofollow noreferrer">http://www.endyourif.com/integrating-automapper-with-an-mvc-result-filter/</a></p>