title: Unity IoC : Create instance of an interface without constructor dependency injection
body: <p>I am kind of new to Unity and DI terminology, hence trying to understand how does it work. I have following code which implements DI using Unity container.</p>
  
  <pre><code>public class DashboardService: IDashboardService
  {
      private readonly IRepository&lt;USERROLE&gt; repoUserRole;
      private readonly IRepository&lt;INSTITUTION&gt; repoInstitution;
  
      public DashboardService(
          IRepository&lt;USERROLE&gt; repoUserRole, IRepository&lt;INSTITUTION&gt; repoInstitution)
      {
          this.repoUserRole = repoUserRole;
          this.repoInstitution = repoInstitution;
      }
  
      public List&lt;USERROLE&gt; GET(List&lt;string&gt; Id)
      {
          // Use repoUserRole object to get data from database
      }
  }
  </code></pre>
  
  <p>This service is being called by the controller:</p>
  
  <pre><code>public class DashboardController : ApiController
  {
      private readonly IDashboardService dashboardService;
  
      public DashboardController(IDashboardService dashboardService)
      {
          this.dashboardService = dashboardService;
          this.mapper = mapper;
      }
  
      //Action method which uses dashboardService object
  }
  </code></pre>
  
  <p>Here is the Unity configuration:</p>
  
  <pre><code>var container = new UnityContainer();
  
  container.RegisterType(typeof(IDashboardService), typeof(DashboardService))
  .RegisterType(typeof(IRepository&lt;&gt;), typeof(Repository&lt;&gt;));
  
  return container;
  </code></pre>
  
  <p><strong>Questions:</strong></p>
  
  <ol>
  <li>As of now, my code works fine, but if I comment out the <code>DashboardService</code> constructor, I am getting the null repository objects.</li>
  <li>I am resolving the dependencies in <code>Unity</code> for repository interfaces, so why I am getting null there?</li>
  <li>Is there any way to pass the repository dependancy without using the constructor pattern? </li>
  </ol>