我是新手,获取传递到目录的错误模型项的类型为 system.clection.generic.list 但此目录需要 system.collection.ienumerable
请帮我解决这个错误。我正在粘贴我的控制器并在此处查看
控制器
public ActionResult DisplayComment()
{
var result = Manager.GetUsersWhoHaveConsumedFreeCredit();
JavaScriptSerializer serializer = new JavaScriptSerializer();
var callHistory = serializer.Deserialize<List<CallHistory>>(result);
YelloAdminDbContext db = new YelloAdminDbContext();
if (callHistory != null)
{
foreach (var item in callHistory.ToList())
{
int Id = int.Parse(item.Login);
var note = db.Note.OrderByDescending(i => i.Id).Where(i => i.LoginId == Id).FirstOrDefault();
if (note != null && note.LoginId == Id)
{
var temp = note.Comments.ToList();
return PartialView(temp);
}
else
return Content("No Comments");
}
}
return Content("No Comments");
}
看法
@model IEnumerable<MyYello.Admin.Models.CallNote>
<table>
<tr>
<th>
@Html.DisplayNameFor(model => model.Comments)
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Comments)
</td>
</tr>
}
</table>