This project is read-only.

Querying for Unpublished Content Parts

Topics: Customizing Orchard
Dec 30, 2014 at 9:35 PM
I currently have a controller that grabs and displays all the instances of a content part using the IContentManager query method. This however only grabs instances that are currently published. As soon as I unpublish an instance of this content part it will no longer show in the list. Is there a way to query for all versions (published, unpublished) of a content part? Thank you.

Note: my queries are as follows
var items = _contentManager.Query<GoldSliderPart, GoldSliderPartRecord>().OrderBy(i => i.Sort).List();
var items = _contentManager.Query("GoldSliderGroup").List();
Dec 30, 2014 at 9:49 PM
Figured it out, somebody else had the same question that got answered already, should have looked around a little more first, sorry.

The answer was to set the version options in my query thusly:

var items = _contentManager.Query<GoldSliderPart, GoldSliderPartRecord>(VersionOptions.Latest).OrderBy(i => i.Sort).List();
Marked as answer by emeraldarcher on 12/30/2014 at 1:49 PM