本文介绍了Tridion:替换 Query.QueryOperator 方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

Query.QueryOperator.AND_Field我们在 Tridion R5.3 VBscript 模板中使用了这种方法,并且效果很好.最近,在迁移到 Tridion 2011 SP1 时,我们尝试使用此方法,但它不起作用.我们了解到此方法在新的 tridion 版本中已弃用.

Query.QueryOperator.AND_FieldWe were using this method in Tridion R5.3 VBscript templates and it worked well.Recently , while migrating to Tridion 2011 SP1, we tried using this method, but it doesn't works.We understood that this method is depreciated in new tridion versions.

根据论坛中的一些帖子,我们还在 CD_Storage_Conf 中启用了以下几行:

As per some posts in Forum, we also enabled the following lines in 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 查询机制?

The question is, what is replacement of the 'Query.QueryOperator.AND_Field' method? How can we use this filter in C# ?How to use the Broker Querying Mechanism mentioned in the support API files?

谢谢.

推荐答案

在 SDL Tridion 2011 Content Delivery 中,您可以创建一个 Query 对象并向其添加一个 Criteria 对象使用 setCriteria 方法.Query 对象ONLY 接受一个 Criteria 对象,但该 Criteria 对象可以反过来引用其他 Criteria 对象树结构.

In SDL Tridion 2011 Content Delivery, you create a Query object and add a Criteria object to it using the setCriteria method. The Query object accepts one Criteria object ONLY, but that Criteria object can in turn reference other Criteria objects in a tree structure.

有关使用 AND 和 OR 运算符创建查询过滤器的很好示例,请参阅SDL LiveContent 中的 SDL Tridion 2011 SP1 文档中的创建过滤器.

For a good example of creating a Query filter using both AND and OR operators, see Creating a filter in the SDL Tridion 2011 SP1 documentation in SDL LiveContent.

// 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;

这篇关于Tridion:替换 Query.QueryOperator 方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 21:01