I am using asp.net MVC 4 and razor syntax. I have a custom model, imagine this:
namespace MyProject.SampleModel
{
public class MyCustomModel
{
public bool MyBoolean1 { get; set; }
public bool MyBoolean2 { get; set; }
}
}
so from the view, in the header, I do:
@model MyProject.SampleModel.MyCustomModel
(...)
@Html.CheckBoxFor(m => m.MyBoolean1 ) <---- ERROR HERE: MyBoolean1 is not recognized
(...)
But in line CheckBoxFor, in the lambda, my MyBoolean1 is not recognized. Why?
First attempt:
It seems like replacing
@model MyProject.SampleModel.MyCustomModel
with:
@using MyProject.SampleModel
there are no compilation errors but in runtime an error is raised:
Compiler Error Message: CS1963: An expression tree may not contain a dynamic operation