title: Which pattern to use to copy all properties from instance of parent class to instance of child class?
body: <p>I strongly feel that what I'm looking for is something quite basic, nevertheless nothing smart comes to my mind right now, so I'm asking for your help.</p>
  
  <p>There is a base class A:</p>
  
  <pre><code>class A 
  {
     string Code {get;set;}
  }
  </code></pre>
  
  <p>and a child blass B:</p>
  
  <pre><code>class B : A 
  {  
      DateTime ValidFrom {get;set;} 
      DateTime? ValidTo {get;set;} 
  }
  </code></pre>
  
  <p>Imagine that there is now an instance of class A, e.g., loaded from Repository:</p>
  
  <pre><code>A a = Repository.GetById(1);
  </code></pre>
  
  <p>What is the most advisable approach for getting an instance of B which derives all the values a currently has (keeping in mind there might be more properties be added to both of the classes) ? Is there a name for this common pattern?</p>
  
  <p>Thanks for your thoughts.</p>