Antaris / RazorEngine

Open source templating engine based on Microsoft's Razor parsing engine
http://antaris.github.io/RazorEngine
Other
2.13k stars 578 forks source link

'object' does not contain a definition for 'id' why? #572

Open yuanfeng-net opened 3 years ago

yuanfeng-net commented 3 years ago

dynamic viewBag = new DynamicViewBag();

viewBag.Item=new {id=100,name="testItem" };

var model=new PageDetail(){};

RunCompile('div>@ViewBag.Item.id</div', 'testitemid', model.GetType(), model, (DynamicViewBag)viewBag);

Microsoft.CSharp.RuntimeBinder.RuntimeBinderException:“'object' does not contain a definition for 'id'”

yuanfeng-net commented 3 years ago

Could you tell me how to solve this?