title: Dapper can't find POCO mapping from SELECT CASE query
body: <p>I'm extracting information from a SQL Server database using Dapper. The POCO for the information in question is below.</p>
  
  <pre><code>public class Client
      {
          public string ShortName { get; set; }
          public string ContactDetail { get; set; }
          public string Street { get; set; }
          public string District { get; set; }
          public string Town { get; set; }
          public string County { get; set; }
          public string Postcode { get; set; }
      }
  </code></pre>
  
  <p>When I extract the information for the above object using the query below all the information is mapped correctly, apart from the following line <code>max(case when cd.Type = 1 OR cd.Type = 2 then cd.Detail end) as 'ContactDetail'</code> I believe this may be because I am not simply extracting the data from a table column and I am instead doing some processing using the CASE clause beforehand and therefore Dapper cannot find the correct place to map the information onto.</p>
  
  <p>I thought including the <code>AS</code> clause would help Dapper to find the correct mapping but this didn't actually work.</p>
  
  <p>How can I change my query so that Dapper can map the ContactDetail data correctly?</p>
  
  <pre><code>select 
  tp.ShortName as 'ShortName', 
  max(case when cd.Type = 1 OR cd.Type = 2 then cd.Detail end) as 'ContactDetail',
  tp.Street, 
  tp.District, 
  tp.Town, 
  tp.County, 
  tp.PostCode
  ... (rest of query snipped as unneeded)
  </code></pre>
  
  <p>I know the query works correctly as I can run it in SSMS and it returns the correct information.</p>