------解决方案--------------------------------------------------------
var view = from pe in project_employee
where pe.id == 16
select new Project_Employee{ empName=pe.employees.empName, projectRote =pe.projectRote };
ViewData["pe"]=view.ToList();
------解决方案--------------------------------------------------------
一般 都用强类型,不用匿名类型。
- C# code
//匿名类型 var view = ....select new { empName=pe.employees.empName, pe.projectRote }; ViewData["pe"]=view.ToList(); //前台 foreach (var item in (IEnumerable<object>)ViewData["pe"]) { var empName = item.GetType().GetProperty("empName").GetValue(item, null); var projectRote = item.GetType().GetProperty("projectRote").GetValue(item, null); }