In sitecore get all child and grand child items using fast query

Soni picture Soni · Feb 27, 2014 · Viewed 11.5k times · Source

In sitecore i want to get all child and grand child which inherited form "Industrial Product template .

Below are the fast query , but its giving error Error : End of string expected at position 5.

Fast query:

_masterdb.SelectItems("query:/sitecore/content/Product Catalog/Industrial/Products/*[@@templatename='Industrial Product']")

Answer

user459491 picture user459491 · Feb 27, 2014

This is not fast query, you are using normal query . Please use something like :

Sitecore.Data.Items.Item[] items = 
 database.SelectItems("fast:/sitecore/content/Product Catalog/Industrial/Products//*[@@templateid='yourTemplateId']"); 

Also please use @@templateid not @@templatename, I made some tests and it's faster using @@templateid.

Also have a look here about using FastQuery.