title: How to Per-Request caching in ASP.net core
body: <p>My old code looks like this:</p>
  <pre class="lang-cs prettyprint-override"><code>public static class DbHelper {
      // One conection per request
      public static Database CurrentDb() {
          if (HttpContext.Current.Items[&quot;CurrentDb&quot;] == null) {
              var retval = new DatabaseWithMVCMiniProfiler(&quot;MainConnectionString&quot;);
              HttpContext.Current.Items[&quot;CurrentDb&quot;] = retval;
              return retval;
          }
          return (Database)HttpContext.Current.Items[&quot;CurrentDb&quot;];
      }
  }
  </code></pre>
  <p>Since we don't have HttpContext anymore easily accesible in core, how can I achieve the same thing?</p>
  <p>I need to access <code>CurrentDb()</code> easily from everywhere</p>
  <p><strong>Would like to use something like MemoryCache, but with Request lifetime. DI it's not an option for this project</strong></p>