title: Map multiple columns to single property with Dapper
body: <p>I'm working with a database that is mildly inconsistent in places. For example, there are two stored procedures that return basically the exact same result set structure, yet, for whatever reason, the DBA named the first field differently in one than the other. I don't want to create two separate models to encapsulate this data.</p>
  
  <p>Is it possible for me to setup Dapper to map both of these result sets to the same object?</p>
  
  <p>For example, <code>sp_GetSomeDataByQtr</code> returns a result set like:</p>
  
  <pre><code>Qtr int,
  Lines int,
  Balance money
  </code></pre>
  
  <p>While, <code>sp_GetSomeDataByMonth</code> returns a result set like:</p>
  
  <pre><code>Mo int,
  Lines int,
  Balance money
  </code></pre>
  
  <p>I want to encapsulate both of these into an object like</p>
  
  <pre><code>public class MyData {
      public int Term { get; set; } //This would be Qtr OR Mo depending on which SP is called.
      public int Lines { get; set; }
      public decimal Balance { get; set; }
  }
  </code></pre>
  
  <p>So, then with Dapper:</p>
  
  <pre><code>MyData data = connection.Query&lt;MyData&gt;("sp_GetSomeDataByQtr", ...).FirstOrDefault();
  </code></pre>
  
  <p>or:</p>
  
  <pre><code>MyData data = connection.Query&lt;MyData&gt;("sp_GetSomeDataByMonth", ...).FirstOrDefault();
  </code></pre>
  
  <p>We can't change the Stored Procedures directly because there are legacy applications also retrieving data from them, and depending on these column names.</p>
  
  <p>Is there a way to do this with Dapper? I know you can setup custom type maps, but I'm not sure how to do it when trying to map multiple columns names to a single property of an object.</p>