title: Automapper Guid to string mapping fails with NullReferenceException if used with Queryable Extensions
body: <p>I'm having a problem with one of my mappings that I can't seem to resolve. 
  Here is the model:</p>
  
  <pre><code>public class Order
  {
      public virtual Guid Id { get; set; }
      public virtual Client Client { get; set; }
  }
  
  public class Client
  {
      public virtual Guid Id { get; set; }
      public virtual string Name { get; set; }
      public virtual string Code { get; set; }
  }
  </code></pre>
  
  <p>Here is the class I'm mapping to:</p>
  
  <pre><code>public class OrderDto
  {
      public string Id { get; set; }
      public string ClientCode { get; set; }
  }
  </code></pre>
  
  <p>Mapping and the test:</p>
  
  <pre><code>public class AutomapperTest
  {
      public AutomapperTest()
      {
          Mapper.Initialize(cfg =&gt; cfg.CreateMap&lt;Order, OrderDto&gt;()
              .ForMember(dto =&gt; dto.Id, conf =&gt; conf.MapFrom(p =&gt; p.Id))
              .ForMember(dto =&gt; dto.ClientCode, conf =&gt; conf.MapFrom(p =&gt; p.Client.Code)));
          Mapper.AssertConfigurationIsValid();
      }
  
      [Fact]
      public void MappingTest()
      {
          Client client = new Client { Id = Guid.NewGuid(), Code = "CTS" };
          Order order = new Order { Id = Guid.NewGuid(), Client = client };
          List&lt;Order&gt; orders = new List&lt;Order&gt; { order };
  
          List&lt;OrderDto&gt; list = orders.AsQueryable().Project().To&lt;OrderDto&gt;().ToList();
      }
  }
  </code></pre>
  
  <p>Test fails with a NullReferenceException on an attempt to project the list of OrderDto objects. Here is the exception, which comes from Automapper:</p>
  
  <pre><code>System.NullReferenceException
  Object reference not set to an instance of an object.
     at AutoMapper.QueryableExtensions.Extensions.CreateMapExpression(IMappingEngine mappingEngine, Type typeIn, Type typeOut) in QueryableExtensions.cs: line 50
     at AutoMapper.QueryableExtensions.Extensions.CreateMapExpression(IMappingEngine mappingEngine, Type typeIn, Type typeOut) in QueryableExtensions.cs: line 136
     at AutoMapper.QueryableExtensions.Extensions.&lt;&gt;c__DisplayClass1`2.&lt;CreateMapExpression&gt;b__0(TypePair tp) in QueryableExtensions.cs: line 24
     at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
     at AutoMapper.Internal.DictionaryFactoryOverride.ConcurrentDictionaryImpl`2.GetOrAdd(TKey key, Func`2 valueFactory) in ConcurrentDictionaryFactory.cs: line 37
     at AutoMapper.QueryableExtensions.Extensions.CreateMapExpression(IMappingEngine mappingEngine) in QueryableExtensions.cs: line 21
     at AutoMapper.QueryableExtensions.ProjectionExpression`1.To() in QueryableExtensions.cs: line 251
     at AutoMapperIssue.AutomapperTest.MappingTest() in Class1.cs: line 47
  </code></pre>
  
  <p>Mapping works just fine if Queryable Extension is not used:</p>
  
  <pre><code>List&lt;OrderDto&gt; dtos = Mapper.Map&lt;List&lt;Order&gt;, List&lt;OrderDto&gt;&gt;(orders);
  </code></pre>
  
  <p>Am I missing something?</p>
  
  <p>Just an update:
  I'm using it with NHibernate, getting identical exception.</p>
  
  <pre><code>var fromDb = Session.Query&lt;Order&gt;().Project().To&lt;OrderDto&gt;().ToList();
  </code></pre>
  
  <p>Seems like it chokes on Guid to string conversion. If i comment the Id field out, it works fine for both NHibernate and collection.AsQueryable().</p>
  
  <pre><code>private static LambdaExpression CreateMapExpression(IMappingEngine mappingEngine, Type typeIn, Type typeOut)
  {
      var typeMap = mappingEngine.ConfigurationProvider.FindTypeMapFor(typeIn, typeOut);
      ...
      foreach (var propertyMap in typeMap.GetPropertyMaps().Where(pm =&gt; pm.CanResolveValue()))
      {
      ...
      }
  }
  </code></pre>
  
  <p>it fails on foreach since typeMap is null. typeIn = System.Guid   typeOut = System.String</p>