我是EPiSERVER的新手。目前正在尝试搜索特定属性设置为特定值的页面。
我需要属性CatalogEntryPoint(ContentReference)来等于某事。这是criterea:
PropertyCriteria secCriteria = new PropertyCriteria();
secCriteria.Condition = CompareCondition.Equal;
secCriteria.Name = "CatalogEntryPoint.ID";
secCriteria.Type = PropertyDataType.Number;
secCriteria.Value = currentContent.ContentLink.ID.ToString();
secCriteria.Required = true;
以下是搜索索引的摘录:
{
"CatalogEntryPoint": {
"$type": "EPiServer.Find.Cms.IndexableContentReference, EPiServer.Find.Cms",
"ID$$number": 1073742170,
"WorkID$$number": 0,
"ProviderName$$string": "CatalogContent",
"GetPublishedOrLatest$$bool": false,
"IsExternalProvider$$bool": true,
"___types": [
"EPiServer.Find.Cms.IndexableContentReference",
"EPiServer.Core.ContentReference",
"System.Object",
"System.IComparable",
"EPiServer.Data.Entity.IReadOnly"
]
},
似乎CatalogEntryPoint.ID符号不起作用,因为我得到0结果。我该怎么写呢?
答案 0 :(得分:2)
PropertyDataType具有ContentReference选项。以下应该有效:
PropertyCriteria secCriteria = new PropertyCriteria();
secCriteria.Condition = CompareCondition.Equal;
secCriteria.Name = "CatalogEntryPoint";
secCriteria.Type = PropertyDataType.ContentReference;
secCriteria.Value = currentContent.ContentLink.ToString();
secCriteria.Required = true;
您也可以ContentLink.ID.ToString()
,代码ContentLink.ToString()
会保留我认为的内容版本。