title: Automapper exception
body: <p>The following mapping code causes automapper to throw an exception when the map is done. </p>
  
  <pre><code>mapper.CreateMap&lt;SqlDataReader, CodeModel&gt;()
        .ForMember(dest =&gt; dest.Code, 
                   options =&gt; options.MapFrom(src =&gt; src["code"] != null ? 
                                                     src["code"].ToString() :
                                                     string.Empty));
  </code></pre>
  
  <p>This is really bizarre, <code>src["code"]</code> has a value, it is <code>"E"</code>, this is even stated in the automapper message.</p>
  
  <p>Does anyone have any insight into what this issue or how to solve this issue? </p>
  
  <p>Stack Trace:</p>
  
  <blockquote>
    <p>[NullReferenceException: Object reference not set to an instance of an
    object.]    AutoMapper.Mappers.TypeMapMapper.Map(ResolutionContext
    context, IMappingEngineRunner mapper) +116<br>
    AutoMapper.MappingEngine.AutoMapper.IMappingEngineRunner.Map(ResolutionContext
    context) +459</p>
    
    <p>[AutoMapperMappingException: </p>
    
    <p>Mapping types: String -> String System.String -> System.String</p>
    
    <p>Destination path: CodeModel.Code</p>
    
    <p>Source value: E]<br>
    AutoMapper.MappingEngine.AutoMapper.IMappingEngineRunner.Map(ResolutionContext
    context) +537<br>
    AutoMapper.Mappers.DataReaderMapper.MapPropertyValue(ResolutionContext
    context, IMappingEngineRunner mapper, Object mappedObject, PropertyMap
    propertyMap) +305<br>
    AutoMapper.Mappers.DataReaderMapper.MapPropertyValues(ResolutionContext
    context, IMappingEngineRunner mapper, Object result) +210<br>
    AutoMapper.Mappers.DataReaderMapper.Map(ResolutionContext context,
    IMappingEngineRunner mapper) +639<br>
    AutoMapper.MappingEngine.AutoMapper.IMappingEngineRunner.Map(ResolutionContext
    context) +477    AutoMapper.MappingEngine.Map(Object source, Type
    sourceType, Type destinationType, Action<code>1 opts) +176<br>
    AutoMapper.MappingEngine.Map(Object source, Action</code>1 opts) +162<br>
    AutoMapper.MappingEngine.Map(Object source) +143</p>
  </blockquote>