Phil Haack posted about this way to do it using a generated class.
You create a .cshtml file and then use a compile time extension on the file to generate a class. Then you can just do this:
var template = new RazorTemplate {
Model = new[] {
new {Name = "Scott", Id = 1},
new {Name = "Steve", Id = 2},
new {Name = "Phil", Id = 3},
new {Name = "David", Id = 4}
}
};
Console.WriteLine(template.TransformText());