我收到的错误是:
传递到字典中的模型项的类型为'System.Data.Entity.Infrastructure.DbQuery 1[System.Collections.Generic.List
1 [RTDOTNET.Song]]',但此字典需要类型为'System.Collections的模型项.Generic.List`1 [RTDOTNET.Song]”。
听起来我使用了错误的模型类型,但我不确定我应该使用哪种类型。
这是我的控制器:
public ActionResult Index()
{
var theSongList = from u in db.Users
join s in db.Songs
on u.UserId equals s.UserId
into newSongList
select newSongList.ToList();
ViewBag.Message = "Current Song";
return View(theSongList);
}
这是观点:
@model List<RTDOTNET.Song>
答案 0 :(得分:4)
您要返回想要结果列表的查询列表,请将其更改为:
var theSongList = (from u in db.Users
join s in db.Songs
on u.UserId equals s.UserId
into newSongList
select newSongList).ToList();
添加()将为您提供结果。