Sitecore Query Builder And Query Types

The SitecoreQueryBuilder object is a super class of the standard Lucinq Query Builder, it supports all of the default querying found here as well as the following additional query types. It also returns Sitecore Items by default in place of Lucene.Net Document objects.

Field()
Gets the items by field value. This results in a term / wildcard or phrase query depending on whether the search string contains spaces, ‘*’.

Example Usage:

            ISitecoreQueryBuilder queryBuilder = new SitecoreQueryBuilder();
            queryBuilder.Field("page_title", "ford");

TemplateDerivesFrom()
Gets items based on them having the given template in their template hierarchy. This results in a term query using a string representation of the templates short id.

Example Usage:

            ISitecoreQueryBuilder queryBuilder = new SitecoreQueryBuilder();
            queryBuilder.TemplateDescendsFrom(SitecoreIds.AdvertTemplateId);

DescendantOf()

Example Usage:

            var queryBuilder = new SitecoreQueryBuilder();
            queryBuilder.DescendantOf(SitecoreIds.MakesPageId);

ChildOf()

This results in a term query using a string representation of the ID specified as a short id.

Example Usage:

            SitecoreQueryBuilder queryBuilder = new SitecoreQueryBuilder();
            queryBuilder.ChildOf(SitecoreIds.HomeItemId);

Id()
This results in a term query using a string representation of the items short id.

Example Usage:

            ISitecoreQueryBuilder queryBuilder = new SitecoreQueryBuilder();
            queryBuilder.Id(new ID("my id"));

Name()
Gets the items by their name. This results in a term / phrase / wildcard query using a string representation of the items short id.

Example Usage:

            ISitecoreQueryBuilder queryBuilder = new SitecoreQueryBuilder();
            queryBuilder.Name("ford");

Language()

Adds language criteria to your query.

            ISitecoreQueryBuilder queryBuilder = new SitecoreQueryBuilder();
            Language language = Language.Parse("de-DE");
            queryBuilder.Language(language);
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s