title: Deserialize Dapper Query into Model
body: <p>I have two models:</p>
  
  <pre><code> public class RuleValidation
  {
      public int RuleId { get; set; }
      public string RuleName { get; set; }
      public int ClientId { get; set; }
      public string ClientName { get; set; }
      public List&lt;RuleException&gt; RuleExcpetions { get; set; }
  }
  </code></pre>
  
  <p>and:</p>
  
  <pre><code> public class RuleException
  {
      public int ExceptionId { get; set; }
      public int RuleId { get; set; }
      public string ExceptionValue { get; set; }
      public string ExcpetionResult { get; set; }
  }
  </code></pre>
  
  <p>I am using the following query to load up the models:</p>
  
  <pre><code> public async Task&lt;RuleValidation&gt; GetRulesByClient(string clientId)
      {
          using (IDbConnection conn = Connection)
          {
              string sQuery = @"SELECT 
                                      Client.Id as 'ClientName',
                                      Client.ClientName, 
                                      Rules.Id,
                                      Rules.RuleName,
                                      Rules.Code, 
                                      RuleException.ExceptionValue, 
                                      RuleException.ExceptionResult
                                FROM 
                                      Rules 
                                LEFT OUTER JOIN
                                      RuleException ON Rules.Id = RuleException.RuleId 
                                RIGHT OUTER JOIN
                                      Client ON Rules.Id = Client.RuleId
                                WHERE
                                      Client.ClientName = @CLIENTID";
              conn.Open();
              var result = await conn.QueryAsync&lt;RuleValidation&gt;(sQuery, new { CLIENTID = clientId });
              return (RuleValidation)result;
          }
      }
  </code></pre>
  
  <p>This seems to deserialize the query into a RuleValidation Object, but the RuleException object is not loading for those records that have exceptions.  So I tried to modify the return like this:</p>
  
  <pre><code> var return= conn.QueryAsync&lt;RuleValidation, RuleException&gt;(
                  sQuery,
                  (ruleValidation, ruleException) =&gt;
                  {
                      ruleValidion.RuleException = ruleException;
                      return return;
                  },
                  splitOn: "RuleId");
  </code></pre>
  
  <p>But I get an error:</p>
  
  <blockquote>
    <p>IDBCOnnection does not contain a definition for QueryAsync and no accessible extension method accepting a first argument of type 'IDBConnection' could not be found</p>
  </blockquote>
  
  <p>Here is how I am setting up my connection (it does work for the initial query)</p>
  
  <pre><code> public IDbConnection Connection
      {
          get
          {
              return new SqlConnection(_configuration.GetConnectionString("ValidationRulesConnectionString"));
          }
      }
  </code></pre>
  
  <p>I am new to dapper and have no problem using it, but this is the first problem I've had that I can't seem to find a solution for in the dapper tutorials or looking online.</p>