Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is fundamental difference between item.Axes.GetDescendants() and item.Axes.selectitems() in sitecore

What is fundamental/Performance difference between item.Axes.GetDescendants() and item.Axes.selectitems() in sitecore?

like image 622
Sunil Aher Avatar asked Sep 01 '25 03:09

Sunil Aher


2 Answers

item.Axes.GetDescendants() get all the descendants of the item using Sitecore API. It calls item.Children, and then for each child again child.Children recursively. And it adds all those items to an array.

item.Axes.Selectitems(string query) executes Sitecore query passed in the argument in the context of the current item.

So those 2 methods are completely different.

like image 71
Marek Musielak Avatar answered Sep 03 '25 13:09

Marek Musielak


item.Axes.selectitems() selects the items based on query provided.It is always good idea to use item.Axes.selectitems() in sitecore instead of GetDescendents as Get Descendents always fetch the child items recursively and has huge performance hit if child items are large in size.

like image 33
Rama Krshna Ila Avatar answered Sep 03 '25 13:09

Rama Krshna Ila