title: How do I create a strongly typed model and use it in the cshtml file as opposed to a dynamic one?
body: <p>I am following <a href="http://haacked.com/archive/2011/08/01/text-templating-using-razor-the-easy-way.aspx" rel="nofollow">this</a> article and I believe it uses a dynamic model, but I want to create a strongly typed model and use it, but I am having a hard time.  Does anyone have an example, I already created a class with a few properties and made several instances of the class that I want to loop through in my cshtml file and generate the output.</p>
  
  <p>Here is the cshtml file:</p>
  
  <pre><code>@* Generator : Template TypeVisibility : Internal *@
  @*@model*@
  
  &lt;table&gt;
  &lt;tr&gt;&lt;th&gt;Name&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;th&gt;Type&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;th&gt;Failed&lt;/th&gt;&lt;/tr&gt;
  @foreach (var item in Model) {
      &lt;tr&gt;&lt;td&gt;@item.Name&lt;/td&gt;&lt;td&gt;@Model.Type&lt;/td&gt;&lt;td&gt;@Model.Failed&lt;/td&gt;&lt;/tr&gt;  
  }
  &lt;/table&gt;
  </code></pre>
  
  <p>Here is the Failures.cs file:</p>
  
  <pre><code>namespace RazorEmailTemplate.Models
  {
      public class PMSFailures
      {
          public string Name { get; set; }
          public string Type { get; set; }
          public DateTime Failed { get; set; }
      }
  }
  </code></pre>
  
  <p>Here is Program.cs:</p>
  
  <pre><code>class Program
      {
          static void Main(string[] args)
          {
              var template = new RazorTemplate
              {
                  Model = new[] {
                  new {Name = "Tru", Type=1, Failed= DateTime.UtcNow},
                  new {Name = "Op", Type=2,Failed= DateTime.UtcNow},
                  new {Name = "Sy", Type=3,Failed= DateTime.UtcNow.AddHours(-16)},
                  new {Name = "Tr", Type=4,Failed= DateTime.UtcNow.AddDays(-3)}
                  }
              };
  
  
              Console.WriteLine(template.TransformText());
              Console.ReadKey();
  
          }
      }
  </code></pre>
  
  <p>The RazorTemplate.cshtml has RazorGenerator as its Custom Tool and it generates a file called RazorTemplate.generated.cs.</p>