title: Injecting Services in constructor vs createScope() in c#
body: <p>I have started to learn c# recently and I am confused with the reason of existance of the method <code>.CreateScope()</code>.</p>
  <p>I have worked on JAVA previously and I can't relate to it. If we need a service as a dependency we can inject it in contructor and then we have it for use.</p>
  <p>From my understanding, we can create a new service scope using it and that may be useful at the time of some bootstraping of app. I read through <a href="https://stackoverflow.com/questions/50200200/net-core-iservicescopefactory-createscope-vs-iserviceprovider-createscope-e">this post of SO </a> , <a href="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/dependency-injection?view=aspnetcore-6.0#resolve-a-service-at-app-start-up" rel="nofollow noreferrer">this one</a> and <a href="https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.iservicescopefactory.createscope?view=dotnet-plat-ext-6.0#Microsoft_Extensions_DependencyInjection_IServiceScopeFactory_CreateScope" rel="nofollow noreferrer">this one from MS</a> but I really think that I have not yet understood its significance.</p>
  <p>I see people creating</p>
  <pre><code>public constructor( IServiceScopeFactory scopeFactory,......)
  {
   this.scopeFactory = scopeFactory;
  }
  </code></pre>
  <p>and then using it in a method as</p>
  <pre><code>using var scope = scopeFactory.CreateScope();
  var mediator = scope.ServiceProvider.GetRequiredService&lt;IMediator&gt;();
  
  await mediator.Send(....);
  </code></pre>
  <p>but we can inject the IMediator as well, right?</p>
  <p>Please help me here. Thanks !</p>