我在控制器中有这段代码
Expression<Func<Title, bool>> filterExpr = null;
Func<IQueryable<Title>, IOrderedQueryable<Title>> orderByFunc = null;
List<Title> titles = unitOfWork.TitleRepository.Get(filter: filterExpr, orderBy: orderByFunc, includeProperties: "").ToList();
return View("Index", titles);
这是模型
public partial class Title
{
public Title()
{
this.NumberTitles = new HashSet<NumberTitle>();
this.Title1 = new HashSet<Title>();
}
public int Id { get; set; }
public string TitleText { get; set; }
public Nullable<int> TitleId { get; set; }
public virtual ICollection<NumberTitle> NumberTitles { get; set; }
public virtual ICollection<Title> Title1 { get; set; }
public virtual Title Title2 { get; set; }
}
这是视图
@model IEnumerable<CinemavaadabiatModel.Title>
<table>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.TitleText)
</td>
</tr>
}
</table>
当我运行它时,我收到以下错误
传入字典的模型项的类型为“System.Collections.Generic.List 1[Project.Title]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable
1[Project.Title]”。我的问题在哪里?