Return to

Valid for Sitecore 6.0.0, 5.3.2
1.  Application
Prev Next

Sitecore Queries are used for populating the lists in lookup-type Sitecore fields and also in the API.

The Source field is used to populate the lookup fields.

1.1.  Specifying the Source

Fill the Source field with a query expression:  

/upload/sdn5/reference/sitecore query/sitecore_query_reference_00.png 

The Source defines a set of Items which will populate the lookup field.

The main benefit of the query expressions is that they make it possible to retrieve plain lists of Items regardless of the content tree hierarchy.

Like XPath, which implements XML Node attributes for the simplification of query creation, Sitecore Query has a set of standard attributes accessed with the '@@' sign. For instance:  

Item fields are accessed by adding the ‘@’ sign. For example: @Title refers to a field called Title.

1.2.  API Application

Please refer to the Internal Architecture section for details concerning the Sitecore Query implementation in the API.

1.3.  Handling the Output

The output of the query expression can be handled by using the following snippet:

public static QueryContext[] GetItemsViaQuery(string sitecoreQuery)
Query query = newQuery(sitecoreQuery);
QueryContext queryContext = newQueryContext(Sitecore.Configuration.Factory.GetDatabase("master").DataManager);
object result = query.Execute(queryContext);
return (QueryContext[])result;

Prev Next