title: .NET Core Register Raw Generic with Different Number of Parameters
body: <p>I'm working on a .NET Core Project.  I need to automatically registers a default for some raw generics.  When there parameter count is the same everything works fine.</p>
  
  <pre><code>public void RegisterServiceDefaults(IServiceCollection services)
  {
       services.AddSingleton(typeof(IAdaptable&lt;,&gt;), typeof(DynamicAdapter&lt;,&gt;));
  }
  </code></pre>
  
  <p>My <code>IAdaptable&lt;TEntity, TDTO&gt;</code> works to allow dynamic adaptation between entities, but in my concrete services by default we expect an interface so we can control how each property is adapted to, my <code>IAdaptable&lt;TEntity, TDTO&gt;</code> is really just a wrapper for convenience on this interface</p>
  
  <pre><code>IAdaptable&lt;TEntity, TIDTO, TDTO&gt;  
      where TDTO: TIDTO
  {
  }
  
  IAdaptable&lt;TEntity, TDTO&gt; : IAdaptable&lt;TEntity, TDTO, TDTO&gt;
  {
  }
  </code></pre>
  
  <p>How can I generically register my adaptables so that if someone requests an <code>IAdaptable&lt;TEntity, TDTO, TDTO&gt;</code> it will by default return the <code>IAdaptable&lt;TEntity, TDTO&gt;</code>?</p>
  
  <p><strong>EDIT Provided for understanding the problem TL;DR</strong></p>
  
  <p>This is being used for a rest framework which provides two ways of registration, the end user can create an <code>IAdaptable&lt;TEntity, TIDTO, TDTO&gt;</code>  a sample adapter might looks like so:</p>
  
  <pre><code>public UserAdapter : IAdaptable&lt;User, IUserDTO, UserDTO&gt;, IUserDTO
  {
       User _user;
  
       public UserAdapter(User user)
       {
           this._user = user;
       }
  
  
       public int Id
       {
           get =&gt; this._user.Id;
           set { /*Do nothing you cannot override the server Id*/}
       }
  
       //... The rest of the User Properties
  }
  </code></pre>
  
  <p>When a the end user creates a service they can use an <code>IAdaptable&lt;TEntity, TIDTO, TDTO&gt;</code> or if they do not want to create a concrete one they can pass some options to the dynamic one which is only aware of the <code>TEntity</code>, and <code>TDTO</code> property, no reason to create an <code>TIDTO</code> when it's only used for adapting.</p>
  
  <p>Now when the end user creates a service they can rely on either interface, the GenericBase service by default requests an IAdaptable like so:</p>
  
  <pre><code>public class RestService&lt;TEntity, TIDTO, TDTO&gt;
      where TDTO: TIDTO
  {
      public RestService(DbContext context, IAdaptable&lt;TEntity, TIDTO, TDTO&gt; adapter, IValidator&lt;TEntity&gt; validator)
      {
      }
  }
  </code></pre>
  
  <p>and for a simplified version:</p>
  
  <pre><code>  public class RestService&lt;TEntity, TDTO&gt; : RestService&lt;TEntity, TDTO, TDTO&gt;
    {
       //Implementation...
    }
  </code></pre>
  
  <p>Now generally speaking, if the end user wants a dynamic adapter they should be using the simplified <code>RestService</code>, but depending on their architecture they maybe implement interfaces on the DTOs or maybe they just used the more explicit base and decide to use the <code>RestService&lt;TEntity, TIDTO, TDTO&gt;</code>,  In which case will leave them with a nasty runtime error.  So to avoid having my support team handle the end user error, I would like to avoid the situation and have the <code>IAdaptable&lt;TEntity,TIDTO, TDTO&gt;</code> work with my dynamic adapter which is a <code>IAdaptable&lt;TEntity,TDTO&gt;</code>.</p>