Created
April 2, 2014 13:46
-
-
Save sniffdk/9934474 to your computer and use it in GitHub Desktop.
Get IContent based on a property value
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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