Using ContentService to get a list Ancestors of certain Content Type
I'm doing my own sorting of pages in the admin site and have an old event handler that was working against Document. I've since upgraded to 6.1.x and am looking at rewriting my event handlers to use the new Content Service.
I'm running into difficulty in retrieving ancestors of a page based on their content type alias. My code is throwing a null reference exception and I can't quite decide if I've found a bug or not....
My event handler is firing on ContentService.Saved.
...global::Umbraco.Core.Events.SaveEventArgs Args)
{
var Service = new ContentService();
using (var SortService = new nodeSorter())
{
var ContactFolder = Service.GetAncestors(e.SavedEntities.First()).FirstOrDefault(x=>x.ContentType.Alias == DocumentTypes.CONTACT_FOLDER);
...
}
}
So I'm getting the null reference exception when trying to access the ContentType property. Can anyone help?
Using ContentService to get a list Ancestors of certain Content Type
I'm doing my own sorting of pages in the admin site and have an old event handler that was working against Document. I've since upgraded to 6.1.x and am looking at rewriting my event handlers to use the new Content Service.
I'm running into difficulty in retrieving ancestors of a page based on their content type alias. My code is throwing a null reference exception and I can't quite decide if I've found a bug or not....
My event handler is firing on ContentService.Saved.
So I'm getting the null reference exception when trying to access the ContentType property. Can anyone help?
Thanks,
Braydie
is working on a reply...