控制器代码
var list = (from c in db.table where c.SUPERVISOR_ID == EmployeeId select new {ID=c.PERSON_ID,Name=c.PERSON_NAME }).ToList();
ViewBag.BrList = list;
return View();
剃刀代码:
@foreach (var br in ViewBag.BrList)
{
<option value="@br.ID">@br.Name</option> //throws error
}
上面提到的代码给出错误 - 'object'不包含'ID'的定义