简体   繁体   English

通过Ektron中的Custom Property获取分类法

[英]Fetching taxonomy by Custom Property in Ektron

I am working in Ektron 9.0. 我正在使用Ektron 9.0。

I have two different custom property associated with a taxonomy in Ektron. 我有两个与Ektron中的分类法相关的不同自定义属性。

Say, Taxonomy called "P",this has got two custom properties, 假设分类法称为“ P”,它具有两个自定义属性,

*P1 *P2 * P1 * P2

Each of these custom property has its own value. 这些自定义属性中的每一个都有其自己的值。

(For eg: *P1 - V1 *P2 -V2) (例如:* P1-V1 * P2 -V2)

Now i am trying to pull all taxonomies in Ektron,based on the names and values of these custom properties. 现在,我试图根据这些自定义属性的名称和值来提取Ektron中的所有分类法。

ie, get all taxonomies in Ektron which has got custom property name as P1 and corresponding value as V1 AND another custom property name as P2 and corresponding value as V2. 即,获得Ektron中的所有分类法,其自定义属性名称为P1,对应的值为V1,另一个自定义属性名称为P2,对应的值为V2。

Code : 代码:

CriteriaFilterGroup<TaxonomyCustomProperty> criteriaFilterGrp1= new CriteriaFilterGroup<TaxonomyCustomProperty>();
criteriaFilterGrp1.AddFilter(TaxonomyCustomProperty.Name,
CriteriaFilterOperator.EqualTo,"P1");
criteriaFilterGrp1.AddFilter(TaxonomyCustomProperty.Value,
                  CriteriaFilterOperator.EqualTo, "V1");
criteriaFilterGrp1.Condition = LogicalOperation.And;
custCtriteria.FilterGroups.Add(criteriaFilterGrp1);

CriteriaFilterGroup<TaxonomyCustomProperty> criteriaFilterGrp2= new CriteriaFilterGroup<TaxonomyCustomProperty>();
criteriaFilterGrp2.AddFilter(TaxonomyCustomProperty.Name,
              CriteriaFilterOperator.EqualTo, "P2";
criteriaFilterGrp2.AddFilter(TaxonomyCustomProperty.Value,
              CriteriaFilterOperator.EqualTo, "V2");
custCtriteria.FilterGroups.Add(criteriaFilterGrp2);

Here,When I Add the Filter criteria by the two taxonomy names and their corresponding value as as follows, I am not getting any results,as it is looking for a taxonomy custom property that satisfies the all four conditions that I have given. 在这里,当我按如下所示按两个分类法名称及其对应值添加“筛选条件”时,没有得到任何结果,因为它正在寻找一个满足我给出的所有四个条件的分类法自定义属性。

How can i resolve this? 我该如何解决?

My guess is that the underlying code is behaving differently from how it might be expected to operate - instead of handling taxonomy items with custom properties, it is handling the properties themselves. 我的猜测是,底层代码的行为方式与预期的方式不同-它不是在处理具有自定义属性的分类项目,而是在处理属性本身。 This is consistent with the behavior of other ektron APIs in terms of its typing, but inconsistent in that it returns the associated taxonomy items themselves (though this is clearly the more desirable outcome). 就其类型而言,这与其他ektron API的行为是一致的,但不一致的是它返回了相关的分类项目本身(尽管这显然是更理想的结果)。 With respect to this design, it makes sense that you cannot retrieve a custom property that has name equal to p1 and p2. 对于这种设计,有意义的是您无法检索名称等于p1 p2的自定义属性。

The solution is to retrieve lists for each property you want to filter by independently, and then intersect these lists. 解决方案是为要筛选的每个属性分别检索列表,然后将这些列表相交。 Conveniently, ektron returns iQueryable lists, so you can do this trivially with linq: ektron方便地返回iQueryable列表,因此您可以使用linq轻松完成此操作:

CriteriaFilterGroup<TaxonomyCustomProperty> criteriaFilterGrp1= new CriteriaFilterGroup<TaxonomyCustomProperty>();
criteriaFilterGrp1.AddFilter(TaxonomyCustomProperty.Name,
CriteriaFilterOperator.EqualTo,"P1");
criteriaFilterGrp1.AddFilter(TaxonomyCustomProperty.Value,
                  CriteriaFilterOperator.EqualTo, "V1");
criteriaFilterGrp1.Condition = LogicalOperation.And;
custCtriteria.FilterGroups.Add(criteriaFilterGrp1);
var itemsWithProp1= taxManager.getList(custCtriteria);

custCtriteria = new criteria();
CriteriaFilterGroup<TaxonomyCustomProperty> criteriaFilterGrp2= new CriteriaFilterGroup<TaxonomyCustomProperty>();
criteriaFilterGrp2.AddFilter(TaxonomyCustomProperty.Name,
              CriteriaFilterOperator.EqualTo, "P2";
criteriaFilterGrp2.AddFilter(TaxonomyCustomProperty.Value,
              CriteriaFilterOperator.EqualTo, "V2");
custCtriteria.FilterGroups.Add(criteriaFilterGrp2);
var itemsWithProp2 = taxManager.getList(custCtriteria);

var itemsWithBoth = itemsWithProp1.Intersect(itemsWithProp2);

While this is not the most elegant or efficient solution, I'm not sure that there is a better way within Ektron's API, outside of crafting a custom SQL query. 虽然这不是最优雅或最有效的解决方案,但我不确定在制作自定义SQL查询之外,Ektron的API中是否有更好的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM