title: Dapper Multi Mapping
body: <p>I've got an object:</p>
  
  <pre><code>public class Species : IEntity&lt;int&gt;
  {
       public int Id { get; set; }
       public string Name { get; set; }
       public SpeciesCategory Category { get; set; }
       public WetlandIndicator WetlandIndicator { get; set; }
  }
  
  public class SpeciesCategory : IEntity&lt;int&gt;
  {
       public int Id { get; set; }
       public string Name { get; set; }
  }
  
  public class WetlandIndicator : IEntity&lt;string&gt;
  {
       public string Id { get; set; }
       public string Designation { get; set; }
       public bool Status { get; set; }
  }
  </code></pre>
  
  <p>However, when I use Dapper to call the following query:</p>
  
  <pre><code>SELECT 
      [Species].*, 
      [SpeciesType].*, 
      [WetlandIndicator].Code AS Id, 
      [WetlandIndicator].Designation 
  FROM 
      ((([Watershed].[Vegetation].[Species] INNER JOIN [Vegetation].[SpeciesCategory] 
          ON [Watershed].[Vegetation].[Species].[SpeciesCategoryId] = [Vegetation].[SpeciesCategory].[Id]) INNER JOIN [Watershed].[Vegetation].[SpeciesType] 
          ON [Watershed].[Vegetation].[Species].[SpeciesTypeId] = [Vegetation].[SpeciesType].[Id]) INNER JOIN [Watershed].[Vegetation].[WetlandIndicator] 
          ON [Vegetation].[Species].[WetlandIndicatorCode] = [Vegetation].[WetlandIndicator].[Code])
  </code></pre>
  
  <p>I receive the make sure when using multi-mapping, make sure you use the <code>splitOn</code> attribute.  Which I am, but I still receive the error.  So I assume I have some type of usage error or syntaxtual error. The code that continually errors is as follows:</p>
  
  <pre><code>public async Task&lt;IEnumerable&lt;SpeciesDomain&gt;&gt; GetAllSpecies(string query) =&gt;
          await dbConnection.QueryAsync&lt;Species, SpeciesCategory, WetlandIndicator, SpeciesDomain&gt;(query, (species, speciesCategory, wetlandIndicator) =&gt;
          {
              species.SpeciesCategory = speciesCategory;
              species.WetlandIndicator = wetlandIndicator;
              return species;
          }, splitOn: "Id, Code");
  </code></pre>
  
  <p>Important Note:  By default Dapper utilizes Id, which is why I renamed Code to Id, but even with Code or the rename I still receive a multi-mapping error.</p>