title: Keeping methods DRY with minor differences in each method
body: <p>I'm writing a conversion class to convert between a model used when pulling API data, do a model used with entity framework. The reason the two are seperated is due to the JSON.Net annotations on the fields, there are conflicts between the ones I need when pulling the data from the api and when using it with entitfy framework &amp; asp.net.</p>
  
  <p>I have a dozen of so classes that are almost identical save for a single field. Here is an example of two conversion methods for those.</p>
  
  <pre><code>public static IEnumerable&lt;PlayerUnitsKilledRank&gt; ConvertPlayerUnitsKilledRankings(IEnumerable&lt;ApiCombatUnitsKilledRank&gt; rankings, int world)
  {
      List&lt;PlayerUnitsKilledRank&gt; dbRankings = new List&lt;PlayerUnitsKilledRank&gt;();
      DateTime now = DateTime.Now.Date;
      foreach (ApiCombatUnitsKilledRank rank in rankings)
      {
          PlayerUnitsKilledRank dbRank = new PlayerUnitsKilledRank()
          {
              Date = now,
              World = world,
              Player = rank.Player,
              Alliance = rank.Alliance,
              Rank = rank.Rank,
              UnitsKilled = rank.UnitsKilled
          };
          dbRankings.Add(dbRank);
      }
      return dbRankings;
  }
  
  public static IEnumerable&lt;PlayerCavernRaidingRank&gt; ConvertPlayerCavernRaidingRankings(IEnumerable&lt;ApiRaidingCavernRank&gt; rankings, int world)
  {
      List&lt;PlayerCavernRaidingRank&gt; dbRankings = new List&lt;PlayerCavernRaidingRank&gt;();
      DateTime now = DateTime.Now.Date;
      foreach (ApiRaidingCavernRank rank in rankings)
      {
          PlayerCavernRaidingRank dbRank = new PlayerCavernRaidingRank()
          {
              Date = now,
              World = world,
              Player = rank.Player,
              Alliance = rank.Alliance,
              Rank = rank.Rank,
              Plundered = rank.ResourcesPlundered
          };
          dbRankings.Add(dbRank);
      }
      return dbRankings;
  }
  </code></pre>
  
  <p>How can you this up to remove the redundant code and keep my class DRY? The methods are so similar to each other, but I can't think of a good way to do this off the top of my head.</p>
  
  <p>I could use generic methods, but then I still ahve that single off-property I need to handle. since each of the classes are so similar, I can make a base-class they all inherit from, but the one-off property is still an issue.</p>