Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7908703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:04:13+00:00 2026-06-03T12:04:13+00:00

Is there a reason or something that I am missing that has Sitecore return

  • 0

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)))
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T12:04:16+00:00Added an answer on June 3, 2026 at 12:04 pm

    I would have to believe that the methods in Sitecore should not be named IsAncestorOf and IsDescendantOf. Based on your finding, and quickly looking at the Sitecore code, the methods should really be named IsAncestorOrSelf and IsDescendantOrSelf.

    For this example,

    Sitecore.Data.Items.Item x = //some item;
    Sitecore.Data.Items.Item y = //some item;
    x.Axes.IsAncestorOf(y)
    x.Axes.IsDescendantOf(y)
    

    The IsAncestorOf method is comparing x.ID == y.ID. It will then keep comparing x.ID to the ID of y’s parent, which is why it should be named IsAncestorOrSelf.

    The IsDescendantOf method is comparing if the LongID path of x starts with the LongID path of y. Being that a string always starts with the same string we again see that this method should be named IsDescendantOrSelf.

    FYI, A LongID path looks like this /{11111111-1111-1111-1111-111111111111}/{0DE95AE4-41AB-4D01-9EB0-67441B7C2450}/{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9} and I suspect is used rather than /sitecore/content/home in order to get around the fact that sitecore allows siblings to have the same name.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a reason I am missing that a block within a case statement
I'm guessing the StackOverflow code has something along the lines of a UsersController that
I have a commercial app that has a completely legitimate reason to see the
There must be something I'm missing here. I have this nice, pretty Oracle SQL
Is there a reason to use a single incrementing field for a primary key
Is there any reason why I should close the connection after a query or
Is there any reason why this shouldn't work? [PseudoCode] main() { for (int i
Is there any reason why images are not being displayed if I place it
Is there any reason to use Spring MVC (or other similar frameworks) as a
Is there any reason to do use block initialization, like this: x = Observer.new

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.