title: How to convert a custom complex type to another custom complex type
body: <p>So I have two custom complex types like this (oversimplified for this example):</p>
  
  <pre><code>public class PendingProduct
  {
      public string Name { get; set; }
      public string Description { get; set; }
      public int ColorCount { get; set; }
  }
  </code></pre>
  
  <p>Let's say I need this object to know how to convert itself to another type:</p>
  
  <pre><code>public class Product
  {
      public string Name { get; set; }
      public string Description { get; set; }
      public ProductColors Colors { get; set;}
  }
  </code></pre>
  
  <p>So when I call a method to convert PendingProduct to Product, I'll execute some custom logic that adds "ColorCount" number of ProductColor objects to the Product class. This is totally oversimplified, but the architecture of the class is really irrelevant here. </p>
  
  <p>What my main question is, is this:</p>
  
  <p>What's the best practice method to use to implement the conversion of one complex type to another complex type when the properties of the objects differ?</p>
  
  <p>In the real world, the properties are very different and I will be writing some custom logic to map what I need from Object A to Object B.</p>
  
  <p>Obviously I could just write a function which takes an input parameter of Object A and returns Object B, but I'm looking for a more "Best Practice" method. Does IConvertible come into play here? Is there something more OOP-like that I can take advantage of rather than just writing a function to do what I want?</p>
  
  <p>Object A should always know how to convert itself to Object B.</p>
  
  <p><strong>EDIT:</strong> As a side note, in the real world, Object A and Object B are both Entity Framework 4 entities. I want to take a "Pending Product", convert it to a new Product entity, attach it to the data context and save.</p>