title: How do I get all of the property names from a model?
body: <p>I need to get all properties name of a model which is init on run time in HtmlHelper extension. I cannot use Type.GetType inside helper because it returns null. </p>
  
  <p>Model Code:</p>
  
  <pre><code>public class SampleVm
  {
      public object ResultObject { get; set; }
  
      public dynamic ResultDynamic { get; set; }
  }
  </code></pre>
  
  <p>View Code:</p>
  
  <pre><code>@Html.SampleResult(m =&gt; m. ResultDynamic)    // this is error, I don’t know why
  @Html.SampleResult(m =&gt; m. ResultObject)   // this works
  </code></pre>
  
  <p>Controller Code:</p>
  
  <pre><code>public ActionResult Index()
  {
      SearchVm vm = new SearchVm();
      vm.ResultObject = Type.GetType("MvcApplication4.Models.Sample.SampleMasterModel");
      vm.ResultDynamic = Type.GetType("MvcApplication4.Models.Sample.SampleMasterModel");
      return View("Index", vm);
  }
  </code></pre>
  
  <p>HtmlHelper extension Code:</p>
  
  <pre><code>public static HtmlString SearchResult&lt;TModel, TProperty&gt;(this HtmlHelper&lt;TModel&gt; html,
  Expression&lt;Func&lt;TModel, TProperty&gt;&gt; expression)
  {
      TModel model = html.ViewData.Model;
      String propertiesName = ?????
      // I want to get the properties name from ResultDynamic or ResultObject
      // I can found all properties from ResultDynamic in debug but don’t know how to 
      // get it.  For ResultDynamic, I don't know how to get the properties name.
      return new HtmlString();
  }
  </code></pre>