Tridion: Replacement for Query.QueryOperator method?

后端 未结 1 609
我寻月下人不归
我寻月下人不归 2021-01-14 05:36

Query.QueryOperator.AND_Field We were using this method in Tridion R5.3 VBscript templates and it worked well. Recently , while migrating to Tridion 2011

相关标签:
1条回答
  • 2021-01-14 06:20

    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.

    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;
    
    0 讨论(0)
提交回复
热议问题