【发布时间】:2014-02-11 06:26:43
【问题描述】:
我正在使用以下代码..
控制器:
public ActionResult Comments(int? Id)
{
var abccomment= db.xyzComments.Include(c=>c.XYZMasters);
var comments = (from x in abccomment
where Id == x.CcId
select x.Comment).Distinct().ToList();
return View(comments);
}
我的看法是
@model IEnumerable<Pharman.Models.XYZMaster>
@foreach (var item in Model)
{
@item.XYZComment.Comment
}
我收到以下错误:
传入字典的模型项的类型为“System.Collections.Generic.List1[System.String]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable1[farma.Models.XYZMaster]。
请帮助... TIA
【问题讨论】:
-
这与这篇文章类似:- stackoverflow.com/questions/4813307/…
标签: c# asp.net-mvc