title: Converting EditorTemplate into HtmlHelper
body: <p>I originally created an editor template like this</p>
  
  <pre><code>@model MyModel
  var items = // get items
  @Html.DropDownListFor(m =&gt; m.Id, items, new { id = Html.IdFor(m =&gt; m) })
  </code></pre>
  
  <p>which was invoked by</p>
  
  <pre><code>@Html.EditorFor(m =&gt; m.SomeClass)
  </code></pre>
  
  <p>where <code>SomeClass</code> has an <code>Id</code> property. (The <code>IdFor</code> is one of my HTML helpers).</p>
  
  <p>This would generate something like this</p>
  
  <pre><code>&lt;select name="SomeClass.Id" id="SomeClass" /&gt;
  </code></pre>
  
  <p>Now I want to change the editor template into an HTML helper, so that my call looks like this</p>
  
  <pre><code>@Html.CustomEditorFor(m =&gt; m.SomeClass)
  </code></pre>
  
  <p>I'm changing this from a view to helper because its easier for reusability.</p>
  
  <p>This is loosely what I have:</p>
  
  <pre><code>public static MvcHtmlString CustomEditorFor&lt;TModel, TProperty&gt;(this HtmlHelper&lt;TModel&gt; htmlHelper, Expression&lt;Func&lt;TModel, TProperty&gt;&gt; expression)
  {
      var idString = htmlHelper.IdFor(expression);
      var propertyValue = expression.Compile()(htmlHelper.ViewData.Model);
      var items = // get items
      return htmlHelper.DropDownListFor(expression, items, new {id = idString});
  }
  </code></pre>
  
  <p>However, when I call the editor, I get this HTML instead of what I want.</p>
  
  <pre><code>&lt;select name="SomeClass" id="SomeClass" /&gt;
  </code></pre>
  
  <p>How can I modify the expression enough to allow it to "access" the <code>Id</code> property?</p>