title: Generics problem with Unit of Work Pattern
body: <p>I need some help with the design of the Unit of Work + Repository + IoC pattern.  I have several interfaces defined as follows:</p>
  
  <pre><code>public interface IRepository&lt;T&gt;
  {       
      T GetEntity(int id);
  }
  
  public interface IUserRepository : IRepository&lt;User&gt;
  {   
      User GetUserByXyz(int id);
  }
  
  public interface IUnitOfWork
  {
      T Respository&lt;T&gt;() where T : IRepository&lt;T&gt;;
  }
  </code></pre>
  
  <p>I am using Unity to resolve some references.  Here's the implementation of the UoW:</p>
  
  <pre><code>public class UnitOfWork : IUnitOfWork
  {
      public T Respository&lt;T&gt;() where T : IRepository&lt;T&gt;
      {
          var container = new UnityContainer();
          return container.Resolve&lt;T&gt;();
      }
  }
  </code></pre>
  
  <p>Now i am having trouble calling the interface:</p>
  
  <pre><code>User user = _unitOfWork.Respository&lt;IUserRepository&gt;().GetUserByXyz(1);
  </code></pre>
  
  <blockquote>
    <p>The type 'IUserRepository' cannot be used as type parameter 'T' in
    the generic type or method 'IUnitOfWork.Respository()'. There is no
    implicit reference conversion from 'IUserRepository' to
    'IRepository'.</p>
  </blockquote>
  
  <p>How do get around the generic constraint error?</p>