从跟随控制器我得到错误标识符。请查看屏幕截图以便更好地理解。图片附件
控制器:
[ChildActionOnly]
public PartialViewResult _GuestNav()
{
using (var db = new TestWebDbEntities())
{
var categories = db.Categories.(x=>x.SubCategories).ToList();
return PartialView("_GuestNav", categories);
}
}
答案 0 :(得分:0)
一个简单的Select
LINQ方法可以使用Categories
方法将IEnumerable
数据集填充到您希望传递到视图的ToList()
对象中:
[ChildActionOnly]
public PartialViewResult _GuestNav()
{
using (var db = new TestWebDbEntities())
{
var categories = db.Categories.Select(x => x.SubCategories).ToList();
return PartialView("_GuestNav", categories);
}
}