title: Easiest way to use Dapper ORM
body: <p>What is the easiest way to get the output of a Dapper ORM query into the data members of the class that provides the method for the query?</p>
  
  <p>This is my code with a method A (ugly) and B (does not work):</p>
  
  <pre><code>public class MyLab_ClientRef
  {
      public int UserId { get; set; }
      public string ClientId { get; set; }
      // ... more fields ...
  
      public bool GetUser(OracleConnection conn, int UserId, string ClientId)
      {
          bool Ok = false;
          IEnumerable&lt;MyLab_ClientRef&gt; QueryResultRecords =
              conn.Query&lt;MyLab_ClientRef&gt;(@"
                  SELECT *
                  FROM MyLab_ClientRef
                  WHERE UserId   = :UserId
                    AND ClientId = :ClientId",
              new { UserId = UserId, ClientId = ClientId });
          if (QueryResultRecords.Count() == 1)
          {
              // Method A
              MyLab_ClientRef Rec = QueryResultRecords.First(); // works
              CopyRec(Rec, this);                               // ugly
  
              // Method B
              this = QueryResultRecords.First();            // avoids CopyRec, does not work
  
              Ok = true;
          }
          return Ok;
      }
  
      private static void CopyRec(MyLab_ClientRef CR_From, MyLab_ClientRef CR_To)
      {
          CR_To.UserId = CR_From.UserId;
          CR_To.ClientId = CR_From.ClientId;
      }
  }
  </code></pre>
  
  <p>I like to keep the record definition close to the query that gets the record, but don't like to implement a <code>CopyRec</code> method for every table class this way.</p>
  
  <p>Is there no better way to implement this? I tried to write <code>this = ...</code> but that is not possible.</p>
  
  <p>How to write a method B that is better than method A?</p>