title: How to configure AutoMapper with generic types
body: <p>I am trying to implement propertywise version tracking in my entities. Using the schema of <code>TrackedProperty</code> for my trackable properties;</p>
  
  <pre><code>public class PropertyVersion&lt;TValue, TVersion&gt;
  {
      public TVersion Version { get; set; }
      public TValue Value { get; set; }
  }
  
  
  public class TrackedProperty&lt;TValue, TVersion&gt; : List&lt;PropertyVersion&lt;TValue, TVersion&gt;&gt;
  {
  
  }
  </code></pre>
  
  <p>For example, In my repository, I will keep the <code>TrackedFoo</code> object and I will be able to retrieve the data at a specific version (in this case the version is described as a Time object) in <code>Foo</code> from.</p>
  
  <pre><code>public class TrackedFoo
  {
      public string Id { get; set; }
      public TrackedProperty&lt;string, DateTime&gt; Name { get; set; }
  }
  
  public class Foo
  {
      public string Id { get; set; }
      public string Name { get; set; }
  }
  </code></pre>
  
  <p>I would like to keep things generic as much as possible. So I tried to use AutoMapper but I wasn't able to configure it in a generic way which I won't need to configure mapping of every single <code>TrackedTypeX</code> to <code>TypeX</code>.</p>
  
  <p><em>I need to get the last PropertyVersion item in TrackedProperty and map its Value property to a TValue type</em></p>
  
  <p>Can you please help me find a solution for this problem?</p>
  
  <p>I can reduce the  number of variable types (is that what you call the stuff between &lt;> ?, anyway) to single using </p>
  
  <pre><code>DateTrackedProperty&lt;TValue&gt; : TrackedProperty&lt;TValue,DateTime&gt;
  IntegerTrackedProperty&lt;TValue&gt; : TrackedProperty&lt;TValue, int&gt;
  StringTrackedProperty&lt;TValue&gt; : TrackedProperty&lt;TValue, string&gt;
  </code></pre>
  
  <p>I am ok with having to write AutoMapper configuration for these three types.</p>