The InfosetPart content part

InfosetPart is one of Orchard's built-in content parts. It's always automatically attached to every content item of every content type. It represents (and provides access to) the so called infoset of the content item.

The infoset is a simple XML document that is stored along the content item in its ContentItemRecord or if versioned, in the ContentItemVersionRecord. It can store arbitrary data and is commonly used to save content fields' data or data for content parts that needn't be queried. Since the ContentItemRecord and/or ContentItemVersionRecord is always loaded for a content item the infoset is also loaded at all times. Thus anything stored in the infoset can be retrieved quickly, without any subsequent database calls.

Importance for content parts

If a content part needs to store data in the database one of the solutions would be to use a content part record. However such records, if not specifically set for eager-loading, are lazily loaded one by one when using the content item. To overcome this performance issue InfosetPart can be used to store the part's data, eliminating the need for further database queries.

However data stored in the InfosetPart can't be simply queried (i.e. filtered or ordered) using the database engine. By storing data both in the infoset and in the record, however, one can have the best of both worlds: querying is possible using the records but for any other database interaction the records are not loaded.

Orchard contains helper methods to ease the usage of the infoset.

Bertrand Le Roy has written an extensive blogpost about the way and implications of using the InfosetPart.

This page is part of the Orchard Dojo Library!

This page and many others here are part of the open-source, portable package of Orchard 1.x goodies: the Orchard Dojo Library for Orchard 1.x. The Library is freely accessible by anyone; just go to its repository to download its full content (you can even download the textual content of the Library as a big concatenated document in HTML), file issues or fork it! You can even edit it online on Bitbucket, just click on the Edit link in the upper right corner!

Note that the Library also has an Orchard Core version, check it out here!