控制器:
var staffList = (from st in db.tbl_UserRole
join usr in db.tbl_User on st.UserId equals usr.Id
select new
{
_name = usr.Name,
_email = usr.Email,
}
).ToList();
ViewBag.UL = staffList;
查看:
我无法解决此错误 在“@ item._name”上它给出了一个例外“'对象'不包含'_name'的定义”
@foreach (var item in ViewBag.UL) {
<tr>
<td>
@item._name
</td>
<td>
@item._email
</td>
}