1

我正在尝试以编程方式克隆内容项。内置clone()方法还不够,我需要干预部分过程。我尝试克隆的内容项具有类别分类字段。我希望我可以按照以下方式做一些事情:

        var sourceContentItemCategory = sourceContentItem.ContentItem.Category as TaxonomyField;
        var targetContentItemCategory = targetContentItem.ContentItem.Category as TaxonomyField;

        targetContentItemCategory.Terms = sourceContentItemCategory.Terms;

但我明白为什么这不起作用。术语是只读的,如果我没记错的话,每个术语也是它自己的内容项,所以我不能只是将这些东西批发到另一个分类法中。最简单的方法是什么?TaxonomyService 可以帮助我做到这一点吗?

4

1 回答 1

1

我发现这可以在分类服务的帮助下很容易地完成:

var sourceTerms = sourceItem.Item.Category.Terms;
_taxonomyService.UpdateTerms(targetItem, sourceTerms, "[Name of Taxonomy Field = Category]");
于 2015-12-02T13:41:27.987 回答