If the content will not have a common draft, published version will be returned. Check whether page really contains common draft. If there is no publish content - last saved version is returned.
If you want to check what you got back you should look for Status property of ContentVersion type.
You can use one of these:
IEnumerable<ContentVersion> List(ContentReference contentLink);
IEnumerable<ContentVersion> List(ContentReference contentLink, string languageBranch);
then filter out:
Where(v => v.Status != VersionStatus.Published)
Thanks. I've added a check to see if it is the Common Draft and CheckedIn.
Do I still need to make a CreateWritableClone if I want to save the page again?
if (draftPage.IsCommonDraft && draftPage.Status == VersionStatus.CheckedIn)
It appears that EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance<IContentVersionRepository>().LoadCommonDraft is returning published and unpublished pages based on a supplied ContentLink. How do I return only unpublished pages?
var draftRepository = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance<IContentVersionRepository>();
ContentVersion draftPage = draftRepository.LoadCommonDraft(contentLink:MyContentLink, language: Language.Name);