sebasuy
sebasuy

Reputation: 494

Orchard CMS content item's type could not be changed programmatically

I created a content item's instance as follows:

ContentItem ci = _orchardServices.ContentManager.New("ContentTypeA");
_orchardServices.ContentManager.Create(ci, VersionOptions.Published);
ci.As<SomeContentPart>().SomeAttr = value;
...
_orchardServices.ContentManager.Publish(ci);

In another method I need to change it's content type, and I tried the following without success:

ci.TypeDefinition = _contentDefinitionManager.GetTypeDefinition("ContentTypeB");
ci.ContentType = "ContentTypeB";

When I query the Content Item again, its content type is still "ContentTypeA" instead of "ContentTypeB".

Any ideas?

Upvotes: 0

Views: 174

Answers (1)

Bertrand Le Roy
Bertrand Le Roy

Reputation: 17814

Once a content item has been created, you can't change its content type. Well, in theory you could hack into the database and make it work, but it seems like a much better use of your time to just create a new item and copy the data.

Upvotes: 1

Related Questions