title: Drying up code with abstract class in C#
body: <p>Let's say I have a warehouse with some "stuff" and I have some minions to run around this warehouse:</p>
  
  <pre><code>public class Warehouse {
      public T GetItemInfo&lt;T&gt;(int id) where T : IItem, new() {}
  
      public int AddItem&lt;T&gt;(T item) where T : IItem {}
  
      public int RemoveItem&lt;T&gt;(int id) where T : IItem, new() {}
  }
  </code></pre>
  
  <p>with minion interface:</p>
  
  <pre><code>public interface IMinion&lt;T&gt; where T : IItem {
      T GetItemInfo(int id);
      int AddItem&lt;T&gt;(T item);
      int RemoveItem&lt;T&gt;(int id);
  }
  </code></pre>
  
  <p>The <code>PartMinion</code> comes first:</p>
  
  <pre><code>public class PartMinion : IMinion&lt;Part&gt; {
      protected Warehouse wh;
  
      public PartMinion(Warehouse wh) {
          this.wh = wh;
      }
  
      public Parts GetItemInfo(int id) {
          return wh.GetItemInfo&lt;Part&gt;(id);
      }
  
      public int AddItem(int id) {
          return wh.AddItem&lt;Part&gt;(id);
      }
  
      public int RemoveItem(int id) {
          return wh.RemoveItem&lt;Part&gt;(id);
      }
  }
  </code></pre>
  
  <p>But, the <code>FurnitureMinion</code> is mostly the same as the <code>PartMinion</code>:</p>
  
  <pre><code>public class FurnitureMinion : IMinion&lt;Furniture&gt; {
      protected Warehouse wh;
  
      public FurnitureMinion(Warehouse wh) {
          this.wh = wh;
      }
  
      public Furniture GetItemInfo(int id) {
          return wh.GetItemInfo&lt;Furniture&gt;(id);
      }
  
      public int AddItem(int id) {
          return wh.AddItem&lt;Furniture&gt;(id);
      }
  
      public int RemoveItem(int id) {
          return wh.RemoveItem&lt;Furniture&gt;(id);
      }
  
      private IEnumerable&lt;Parts&gt; GetParts(int id) {
          var query = "SELECT * FROM Parts " +
                      "JOIN FurnitureParts ON Parts.ID = FurnitureParts.PartID " +
                      "WHERE FurnitureParts.FurnitureID = ?";
          var result = wh.Query&lt;Parts&gt;(query, id);
          return result;
      }
  }
  </code></pre>
  
  <p>So I'd like to <code>Abstract</code> away the duplicate code between the two, but I can't quite get the syntax right:</p>
  
  <pre><code>public abstract class AbstractMinion : IMinion&lt;T&gt; {
      protected Warehouse wh;
  
      public AbstractMinion(Warehouse wh) {
          this.wh = wh;
      }
  
      public Parts GetItemInfo(int id) {
          return wh.GetItemInfo&lt;T&gt;(id);
      }
  
      public int AddItem(int id) {
          return wh.AddItem&lt;T&gt;(id);
      }
  
      public int RemoveItem(int id) {
          return wh.RemoveItem&lt;T&gt;(id);
      }
  }
  </code></pre>