title: Best way to expose cached objects to the views
body: <p>I am using an Translator object (custom class) to expose website texts (the object stores texts from the database). The Translator object is stored in the cache, in the Application_Start() function.</p>
  
  <p>My current use of the Translator object is:</p>
  
  <ul>
  <li><p>I have a MasterViewModel</p>
  
  <pre><code>public class MasterViewModel
  {
      public Translator Translator = HttpContext.Current.Cache.Get("Translator") as   Translator;
  }
  </code></pre></li>
  <li><p>Every view has a viewmodel, that inherents from MasterViewModel </p>
  
  <pre><code>public class RandomViewModel : MasterViewModel
  {
  }
  </code></pre></li>
  <li><p>In my views i can use my Translator object</p>
  
  <pre><code>@model ViewModels.RandomViewModel
  
  @Model.Translator.GetText(label)
  </code></pre></li>
  </ul>
  
  <p>I don't think this is a nice aproach. 
  Is it a good idea to make a razor helper in App_Code, so that in my views i can use</p>
  
  <pre><code>    @Translate.GetText("RANDOM_TEXT")
  </code></pre>
  
  <p>This will be the Helper function (in Translate.cshtml)</p>
  
  <pre><code>    @helper GetText(string label)
      {
          Translator Translator = @Cache.Get("Translator") as Translator;
          @: Translator.GetTextByLabel(label);
      }
  </code></pre>
  
  <p>So my question is what is the best way of exposing a cached object to all my views.
  Is one of the above approaches good? Or should i go with another solution?</p>
  
  <p>(I hope my english is okay, i am dutch)</p>