9.20.2012

GetChildren() vs GetDescendants() in Sitecore

Differences between GetChildren() and GetDescendants() Methods in Sitecore
S.No
GetChildren()
GetDescendants()
1
How it can be accessed ?
This method can be accessed as follows:
itemObject.GetChildren();
How it can be accessed ?
This method can be accessed as follows: itemObject.Axes.GetDescendants();

2
Items returned by GetChildren():
Returns all the direct children of an item.
i.e. All the items present at level 1 under the item.
Items returned by GetDescendants():
Returns all the items under an item.

3
How to find all the Children using GetChildren() ?
If we need all the children, we need to recursively call GetChildren() method, for all the items under a specific item. This surely gonna consume more time!
How to find all the Children using GetChildren() ?
If we want all the children, then Call GetDescendants() method and we have them all and no recursive calls as like GetChildren(). So that’s where this method seems good.

What is Sitecore ?

Sitecore is a web content management system software company that provides enterprise website, intranet, portal and marketing automation software. The company was founded in 2001 and has offices in Australia, Denmark, Sweden, Canada, Germany, Japan, Netherlands, United Kingdom, and United States.
Sitecore's software is built on Microsoft .NET 3.5/4.0. Content can be stored as XML or .NET objects and Sitecore CMS can leverage either Microsoft SQL Server or Oracle Database for its database storage, though MS SQL Server is the most popular.[citation needed] Sitecore also allows deployment via Microsoft Azure.[1]

Reference:



1 comment: