我创建了一个内容项的实例,如下所示:
ContentItem ci = _orchardServices.ContentManager.New("ContentTypeA");
_orchardServices.ContentManager.Create(ci, VersionOptions.Published);
ci.As<SomeContentPart>().SomeAttr = value;
...
_orchardServices.ContentManager.Publish(ci);
在另一种方法中,我需要更改它的内容类型,我尝试了以下但没有成功:
ci.TypeDefinition = _contentDefinitionManager.GetTypeDefinition("ContentTypeB");
ci.ContentType = "ContentTypeB";
当我再次查询内容项时,其内容类型仍然是“ContentTypeA”而不是“ContentTypeB”。
有什么想法吗?
答案 0 :(得分:1)
创建内容项后,您无法更改其内容类型。好吧,从理论上讲,你可以入侵数据库并使其工作,但似乎更好地利用你的时间来创建一个新项目并复制数据。