Second its not a RazorEngine limitation as the following code shows:
using System;
using System.Linq;
public class Test
{
public static dynamic TestMethod()
{
var a = new[] { "first", "second", "self" };
var ext = a.First();
dynamic c = new[] {"first", "second", "self"};
return c.First();
}
public static void Main(string[] args)
{
string ret = TestMethod();
}
}
try to compile an run it
var tpl = Razor.GetTemplate(templateHtml, new {}, pageCacheKey);
var viewbag = new DynamicViewBag();
var ctx = new ExecuteContext(viewbag);
var result = tpl.Run(ctx);