【发布时间】:2012-12-13 06:13:22
【问题描述】:
我有两个模型说 "Page" 和 "Product" Product's PageID 指的是 Page's ID
在我的产品索引视图中,我需要将页面列表作为下拉列表,因为我正在使用
public ViewResult Index()
{
var products = _db.Products.Include(p => p.Page);
return View(products.ToList());
}
但我只需要那些 PageGroup 属性值为 'Product' 的页面。为此我使用了
public ViewResult Index()
{
var products = _db.Products.Include(p => p.Page.PageGroup
.Contains(PageGroup.Product.ToString()));
return View(products.ToList());
}
报错如下:
包含路径表达式必须引用导航属性 在类型上定义。使用虚线路径进行参考导航 属性和用于集合导航的 Select 运算符 特性。参数名称:路径
【问题讨论】:
标签: asp.net-mvc-3 collections model path