0

下面的代码是用 MVC5 控制器编写的。它会引发错误“对象不包含 Where 的定义”。“IsToShow”是具有控件“true/false”的 DocumentType,它作为组合用于每个 Document Type,其值在 UmbracoNaviHide 等内容模板上设置。

public List<NavigationList> GetSubNavigationList()
 { 
     IPublishedContent page = Umbraco.Content(pageId); 
     var subPages = page.Children.Where("IsToShow");//Error Line 
 }
4

1 回答 1

0

您需要在 U8 中使用 lamdba 和 property/equals 查询 Where 。

var subPages = page.Children.Where(x => x.GetProperty("isToShow").Value().Equals(true));

于 2020-02-14T20:49:11.620 回答