Is there a reason or something that I am missing that has Sitecore return true
for both Item.Axes.IsDescendantOf()
and Item.Axes.IsAncestorOf()
?
var test =
Sitecore.Context.Database.GetItem("{862B466A-079B-40E7-8661-FC064EC28574}");
Response.Write(test.Axes.IsAncestorOf(test));
Response.Write(test.Axes.IsDes(test));
//True
//True
Edit: Anyone whom may stumble across this answer looking for non-inclusive IsAncestorOf
or IsDescendantOf
, below are a couple examples where I need to find the highest level elements in a multi-select field for news categories.
newsCategories
.Where(x => newsCategories
.Any(y => x != y && !x.Axes.IsDescendantOf(y)))
and
newsCategories
.Where(x => newsCategories
.Any(y => x != y && !x.Axes.IsDescendantOf(y)))