Skip to content

Instantly share code, notes, and snippets.

@sniffdk
Created April 2, 2014 13:46
Show Gist options
  • Save sniffdk/9934474 to your computer and use it in GitHub Desktop.
Save sniffdk/9934474 to your computer and use it in GitHub Desktop.
Get IContent based on a property value
var contentService = ApplicationContext.Current.Services.ContentService;
var roots = contentService.GetRootContent();
IContent nodeItem = null;
foreach (var root in roots)
{
nodeItem = contentService.GetDescendants(root).FirstOrDefault(x => x.Properties.FirstOrDefault(y => y.Alias == "somePropertyAlias").Value.ToString() == "SomeValue");
if (nodeItem != null)
break;
}
var test = nodeItem.Name;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment