title: dynamically choose between two labels for the Display Name in mvc ef
body: <p>I am using Entity Framework, MVC. How can I dynamically change between two labels for one data field (based on data retrieved from another database about the same vehicle)? Ideally I would like my Model class to have something like this in it (this is pseudocode and is not expected to compile):</p>
  
  <pre><code>[Display(Name = "resCatalyst", ResourceType = typeof(VehiclesModelResource))]
      public string Catalyst { get; set; }
  ...
  public void SetElementDisplayName(bool DieselOlderThan2009)
      {
          if (DieselOlderThan2009)
          {
              Catalyst.SetDisplayName(Name = "resNMHCCatalyst", ResourceType = typeof(VehiclesModelResource));
          }
          else
          {
              Catalyst.SetDisplayName(Name = "resCatalyst", ResourceType = typeof(VehiclesModelResource));
          }
      }
  </code></pre>
  
  <p>I did think of changing the label in the cshtml file like this:</p>
  
  <pre><code>@if(Model.vltDataOne.FuelType == "D" &amp;&amp; Model.vltDataOne.VehicleYear &gt;= 2009)
              {
                  &lt;p&gt;
                          &lt;b&gt; @Html.LabelFor(model =&gt; model.testObd.Catalyst, @DTResource.resNMHCCatalyst) &lt;/b&gt;
                          @Html.DisplayFor(model =&gt; model.testObd.Catalyst) 
                  &lt;/p&gt;
              }
  else
              {
                  &lt;p&gt;
                          &lt;b&gt; @Html.LabelFor(model =&gt; model.testObd.Catalyst, @DTResource.resCatalyst) &lt;/b&gt;
                          @Html.DisplayFor(model =&gt; model.testObd.Catalyst) 
                  &lt;/p&gt;
              }
  </code></pre>
  
  <p>But I am responding to a business rule and I really think it should be in the Model, not the View. Is there any way to move this logic to the Model? Thanks for any ideas/insights.</p>