Query.QueryOperator.AND_Field我们在 Tridion R5.3 VBscript 模板中使用了这种方法,效果很好。
最近,在迁移到Tridion 2011 SP1时,我们尝试使用此方法,但它不起作用。
我们了解到该方法在新的 tridion 版本中已被弃用。
根据论坛中的一些帖子,我们还在 CD_Storage_Conf 中启用了以下几行:
<SearchFilter Name="SearchFilter" Class="com.tridion.broker.components.meta.MsSqlSearchFilterHome" defaultStorageId="defaultdb"/>
<Item typeMapping="Query" storageId="defaultdb"/>
问题是,“Query.QueryOperator.AND_Field”方法的替换是什么?我们如何在 C# 中使用这个过滤器?
如何使用支持API文件中提到的Broker查询机制?
Thanks.
在 SDL Tridion 2011 Content Delivery 中,您可以创建一个Query
对象并添加一个Criteria
反对它使用setCriteria
方法。这Query
对象接受一个 Criteria 对象ONLY,但是那个Criteria
对象可以依次引用其他对象Criteria
树结构中的对象。
有关使用 AND 和 OR 运算符创建查询过滤器的好示例,请参阅创建过滤器在 SDL LiveContent 的 SDL Tridion 2011 SP1 文档中。
// Schema has ID of either 511 (Article) or 34 (Press Release).
ItemSchemaCriteria IsArticle = new ItemSchemaCriteria(511);
ItemSchemaCriteria IsPressRelease = new ItemSchemaCriteria(34);
Criteria IsArticleOrPressRelease = CriteriaFactory.Or(IsArticle, IsPressRelease);
// Type of the item is 16 (Component).
ItemTypeCriteria IsComponent = new ItemTypeCriteria(16);
// Both of the above conditions must be true
Criteria AllCriteria = CriteriaFactory.And(IsArticleOrPressRelease, IsComponent);
// Add these criteria to a query
Query MyQuery = new Query();
MyQuery.Criteria = AllCriteria;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)