This project is read-only.

How to keep part data in ContentItemRecord level not in ContentItemVersionRecord

Topics: Customizing Orchard
Nov 14, 2014 at 6:28 AM

I will write a contentpart for document control purpose. I want to keep document number, but
I found Orchard_Framework_ContentItemRecord have a data column. How to write content part to keep information in its data field, for example document number which isn't nonversion.

Thanks! Best Regards!
Nov 14, 2014 at 6:41 AM
Why do you want to do that? What's wrong with having this data stored in the Orchard_Framework_ContentItemVersionRecord table?
Nov 14, 2014 at 6:50 AM
Hi sfmskywalker

I am very appreciated. I have studied your every blog. Do you finish your workflow relative for message template? I am want to implement a PDM( product life cycle management) web site. I want content item have version/revision and a document number which system auto generated. The document number is the same for every version/revision. So I want keep the document number in contentitemrecord level. Just for data modeling, data consistent issue. But I can't find document about this.

Waiting your workflow version message template!!!

Thanks! Best Regards!
Nov 14, 2014 at 7:10 AM
Edited Nov 14, 2014 at 7:10 AM
I see. If I understand correctly, you derived your content part record class from ContentPartVersionRecord, but want certain properties to be stored in the Data column of the ContentItemRecord table. You can achieve that by storing and retrieving data from the InfoSet.

For example:
// Notice that the part record is derived from ContentPartVersionRecord
public class MyPartRecord : ContentPartVersionRecord {
   // Your versionable properties go here.

public class MyPart : ContentPart<MyPartRecord> {
   // Non-versioned data to be stored in the Data column of ContentItemRecord:
   public int DocumentNumber {
      get { return Retrieve<int>("DocumentNumber"); }
      set { Store("DocumentNumber", value); }
Thanks for reminding me about that workflow post. I might revisit that at some point, but first I have a new post in mind that will cover the new Dynamic Forms module in conjunction with workflows and sending an email. Sorry, it's hard to resist inspiration. :)
Nov 14, 2014 at 7:21 AM
Hi sfmskywalker

I see, thanks! I have another question about creating part definition to include content field in migration. I have to split document_number into field which is contentitemrecord level.
And include the field into document content part which have version/revision data which is contentitemversionrecord level. How to do ?

Thanks! Best Regards!
Nov 14, 2014 at 7:51 AM
I'm not sure I understand your question.
Content Fields are attached to Content Parts. Do you want your content field to be stored with versioning support, or without version support?
If you look the InfosetStorageProvider, it seems to use the VersionInfoSet when ContentItem.VersionRecord is not null, and InfoSet if it is null. However, I don't know offhand in what scenarios VersionRecord is null. Up to you to find out. Please let us know.