RazorEngine
RazorEngine copied to clipboard
Known Model type with dynamic Property not working
I want to have a model class like this:
class MyModel {
public dynamic Inner { get; set; }
}
but when i want to use it (e.g. with anonymous class with property IsDuplicate) ...
var model = new MyModel() { Inner = new { IsDuplicate = true } }
... the RunCompile method throws this exception: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'object does not contain a definition for IsDuplicate.'
Possible Template:
@model MyModel
@if(Model.Inner.IsDuplicate) { ... }
Do i need to use the RazorDynamicObject class somehow? Or is this functionality not supported?
Thank you for any help!