是否有某个原因或者我缺少Sitecore返回true
对于Item.Axes.IsDescendantOf()
和Item.Axes.IsAncestorOf()
?Sitecore Axes.IsDescendantOf/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));
//真
//真
编辑:任何人可以跨越这个答案找非包容性IsAncestorOf
或IsDescendantOf
绊倒,下面是几个例子,我需要在新闻类别的多选字段中查找最高级别的元素。
newsCategories
.Where(x => newsCategories
.Any(y => x != y && !x.Axes.IsDescendantOf(y)))
和
newsCategories
.Where(x => newsCategories
.Any(y => x != y && !x.Axes.IsDescendantOf(y)))
希望我能给它两个upvotes。 – techphoria414
@ techphoria414同样 –
肖恩,完美地回答了这个问题,我有这样的感觉。我注意到源代码中还有一个IsDescendantOrSelf方法。 – al3xnull