我似乎无法让这个工作。我从这里how to use Linq to get a sitecore field开始,但已经停滞不前了。我正在尝试排除某些页面/模板。这就是我所拥有的:
var query = PredicateBuilder.True<SearchResultItem>();
query = query.And(i => i.Paths.Contains(homeItem.ID));
query = query.And(i => i.Content.Contains(searchTerm));
query = query.And(i => i.TemplateName != "MenuFolder");
query = query.And(i => i["Template"] != "/sitecore/templates/Common/Folder");
最后一个路径为“/ sitecore / templates / Common / Folder”我无法开始工作。我想确保在执行搜索时搜索中没有任何文件夹出现。我使用了Path,Paths,TemplateName,TemplateID的变体,但我似乎无法使它工作。
答案 0 :(得分:2)
尝试执行以下操作:
var query = PredicateBuilder.True<SearchResultItem>();
query = query.And(i => i.Paths.Contains(homeItem.ID));
query = query.And(i => i.Content.Contains(searchTerm));
query = query.And(i => i.TemplateName != "MenuFolder");
query = query.And(i => i.TemplateId != Sitecore.TemplateIDs.Folder);
Sitecore.TemplateIDs.Folder是路径/sitecore/templates/Common/Folder
中文件夹的ID,其ID为{A87A00B1-E6DB-45AB-8B54-636FEC3B5523}
由于