title: Instantiating objects with .NET Core's DI container
body: <p>I'm using an <code>IServiceCollection</code> to create a list of required services for my objects. Now I want to instantiate an object and have the DI container resolve the dependencies for that object</p>
  
  <p><strong>Example</strong></p>
  
  <pre><code>// In my services config.
  services
      .AddTransient&lt;IMyService, MyServiceImpl&gt;();
  
  // the object I want to create.
  class SomeObject
  {
      public SomeObject(IMyService service)
      {
          ...
      }
  }
  </code></pre>
  
  <p>How to I get the DI container to create an object of type <code>SomeObject</code>, with the dependecies injected? <em>(presumably this is what it does for controllers?)</em></p>
  
  <p><strong>Note:</strong> I do not want to store <code>SomeObject</code> in the services collection, I just want to be able to do something like this...</p>
  
  <pre><code>SomeObject obj = startup.ServiceProvider.Resolve&lt;SomeObject&gt;();
  </code></pre>
  
  <p>... Rationale: I don't have to add all of my controllers to the service container, so I don't see why I would have to add <code>SomeObject</code> to it either!?</p>