Tridion:Query.QueryOperator方法的替换?

Hus*_*pes 3 tridion tridion-content-delivery tridion-2011

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"/>
Run Code Online (Sandbox Code Playgroud)

问题是,什么是'Query.QueryOperator.AND_Field'方法的替换?我们如何在C#中使用此过滤器?如何使用支持API文件中提到的Broker查询机制?

谢谢.

Dav*_*ter 6

在SDL Tridion 2011 Content Delivery中,您可以使用该方法创建一个Query对象并向其添加Criteria对象setCriteria.该Query对象接受一个Criteria对象,但该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;
Run Code Online (Sandbox Code Playgroud)