title: Slapper.Automapper with Dapper.net using Guid Ids
body: <p>I need to map a one to many flattened SQL query into nested objects using Dapper.net.</p>
  
  <p>Slapper.Automapper seems a good way of doing this; as detailed in the answer to this question:</p>
  
  <p><a href="https://stackoverflow.com/questions/9350467/how-do-i-write-one-to-many-query-in-dapper-net">How do I write one to many query in Dapper.Net?</a></p>
  
  <p>Erroneous dataset I get using Guids:
  <a href="https://i.stack.imgur.com/JGOgt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JGOgt.png" alt="enter image description here"></a></p>
  
  <pre><code>public string MrFlibble3()
  {
      using (var connection = new SqlConnection(Constr))
      {
          Slapper.AutoMapper.Cache.ClearInstanceCache();
  
          const string sql = @"SELECT tc.[IDG] as ContactIdg
                                  ,tc.[ContactName] as ContactName
                                  ,tp.[Idg] AS TestPhones_PhoneIdg
                                  ,tp.[ContactIdg] AS TestPhones_ContactIdg
                                  ,tp.[Number] AS TestPhones_Number
                                  FROM TestContact tc
                                  INNER JOIN TestPhone tp ON tc.Idg = tp.ContactIdg";
  
          // Step 1: Use Dapper to return the  flat result as a Dynamic.
          dynamic test = connection.Query&lt;dynamic&gt;(sql);
  
          // Step 2: Use Slapper.Automapper for mapping to the POCO Entities.
          // - IMPORTANT: Let Slapper.Automapper know how to do the mapping;
          //   let it know the primary key for each POCO.
          // - Must also use underscore notation ("_") to name parameters;
          //   see Slapper.Automapper docs.
          Slapper.AutoMapper.Configuration.AddIdentifiers(typeof(TestContact), new List&lt;string&gt; { "ContactIDg" });
          Slapper.AutoMapper.Configuration.AddIdentifiers(typeof(TestPhone), new List&lt;string&gt; { "PhoneIdg" });
  
          var testContact = (Slapper.AutoMapper.MapDynamic&lt;TestContact&gt;(test) as IEnumerable&lt;TestContact&gt;).ToList();
  
          string flibblethis = "";
  
          foreach (var c in testContact)
          {
              foreach (var p in c.TestPhones)
              {
                  // Console.Write("ContactName: {0}: Phone: {1}\n", c.ContactName, p.Number);
                  flibblethis += "Contact Name: " + c.ContactName + ". Number: " + p.Number + "&lt;br /&gt;";
              }
          }
  
          return flibblethis;
      }
  }
  </code></pre>
  
  <p>It works well in the example - except Slapper.Automapper doesn't appear to work if Ids are Guids rather than ints.</p>
  
  <p>Is there any way to use Guid IDs with Slapper.Automapper - or is there an alternative way to map this using Dapper.net?</p>
  
  <p>(Slapper.Automapper isn't widely used and I can't see anything online about this issue).</p>