Reference - ContentRetriever API

Experimental API

This API is currently considered experimental. It uses the C# [Experimental] attribute and is subject to change, potentially including breaking changes, in upcoming releases. Using this API will generate a compilation error by default, requiring you to explicitly opt-in by suppressing the specific diagnostic ID (e.g., using #pragma warning disable KXE0003 or project settings).

For more details on the attribute, see the Microsoft documentation.

Page queries

Retrieve the current page

Method: RetrieveCurrentPage<TResult>(...)

Retrieves the page requested by the current HTTP request. The method maps the retrieved data to the specified TResult model.

C#
Basic usage


// Assuming 'ArticlePage' is a generated model class
// For instance, assume the request is handled by 'ArticlesController'
// so 'TResult' always matches the retrieved schema and is mapped correctly.
ArticlePage currentPage =
  await contentRetriever.RetrieveCurrentPage<ArticlePage>();

// If current page can be of multiple types, you can use 'IWebPageFieldsSource'
// or different suitable base class together with pattern matching.
// Suitable model classes are paired with content types using
// 'RegisterContentTypeMappingAttribute' (automatically added to generated classes)
//
// Retrieves the current page using a shared interface
var currentPageData =
  await contentRetriever.RetrieveCurrentPage<IWebPageFieldsSource>();

// Use pattern matching to handle the specific type
switch (currentPageData)
{
  case ArticlePage article:
    // Specific logic for ArticlePage
    Console.WriteLine($"Displaying Article: {article.Title}");
    // Render article view...
    break;

  case LandingPage landing:
    // Specific logic for LandingPage
    Console.WriteLine($"Displaying Landing Page: {landing.Headline}");
    // Render landing page view...
    break;

  case null:
    // Handle case where the page is not found or not retrievable
    Console.WriteLine("Current page not found.");
    // Render 404 view...
    break;

  default:
    // Handle any other unexpected page types
    // Render a default view...
    break;
}

C#
With parameters


// Overrides method defaults with custom parameters
var parameters = new RetrieveCurrentPageParameters
{
    // Force a language variant
    LanguageName = "spanish",
    // Include directly linked items
    LinkedItemsMaxLevel = 1,
    // Force preview mode data
    IsForPreview = true
};

ArticlePage page = await contentRetriever.RetrieveCurrentPage<ArticlePage>(parameters);

C#
All configuration options


// Disable caching
var cacheSettings = RetrievalCacheSettings.CacheDisabled;

ArticlePage page = await contentRetriever.RetrieveCurrentPage<ArticlePage>(
    // Use the default retrieval params
    new RetrieveCurrentPageParameters(),
    // Only get the Title property
    query => query.Columns(nameof(ArticlePage.ArticleTitle)),
    cacheSettings,
    // Explicitly use default mapping
    configureModel: null 
);

RetrieveCurrentPageParameters

Some overloads of RetrieveCurrentPage require an instance of RetrieveCurrentPageParameters. This object allows you to fine-tune how the current page is retrieved.

Property

Default value

Description

IncludeUrlPath

true

Specifies if page URL data should be included in the results. This data is necessary when resolving page URLs and saves a database roundtrip if included.

LinkedItemsMaxLevel

0

Controls the depth of linked content items to retrieve recursively along with the main page. A value of 0 means no linked items are retrieved.

LanguageName

null

Allows you to override the default content language determined by the current context. If left null, the language retrieved from the current HTTP request is used.

UseLanguageFallbacks

true

Determines if the system should attempt to retrieve content in fallback languages if the content is not available in the primary specified language.

IncludeSecuredItems

false

Specifies whether content items requiring special permissions (e.g., secured sections) should be included in the results.

IsForPreview

null

Allows overriding the preview mode context. If left null, the retrieval respects the current website context (whether the request is in preview mode or live). Set to true to force preview data or false to force live data.

Retrieve pages sharing reusable field schema

Method: RetrievePagesOfReusableSchemas<TResult>(...)

Retrieves a collection of pages whose content types uses one or more of the specified reusable field schemas, mapping them to the TResult model. Allows filtering by path, language, and other criteria using RetrievePagesOfReusableSchemasParameters.

C#
Basic usage


// Assuming 'IPageMetadata' is an interface implemented by types using these schemas
var schemaNames = new[] { IMetadataFields.REUSABLE_FIELD_SCHEMA_NAME, ISeoFields.REUSABLE_FIELD_SCHEMA_NAME };

// Gets all pages using the specified schemas with default settings
IEnumerable<IPageMetadata> pagesWithSchemas =
  await contentRetriever.RetrievePagesOfReusableSchemas<IPageMetadata>(schemaNames);

C#
With parameters


var schemaNames = new[] { IMetadataFields.REUSABLE_FIELD_SCHEMA_NAME };

// Retrieve pages using the 'Metadata' schema under the /products path
var parameters = new RetrievePagesOfReusableSchemasParameters
{
    PathMatch = PathMatch.Children("/products")
};

IEnumerable<IPageMetadata> productPages =
  await contentRetriever.RetrievePagesOfReusableSchemas<IPageMetadata>(schemaNames, parameters);

C#
All configuration options


var schemaNames = new[] { IMetadataFields.REUSABLE_FIELD_SCHEMA_NAME, ISeoFields.REUSABLE_FIELD_SCHEMA_NAME };

// Disable caching
var cacheSettings = RetrievalCacheSettings.CacheDisabled;

// Retrieve the top 20 pages using the schemas
IEnumerable<IPageMetadata> pageInfo =
  await contentRetriever.RetrievePagesOfReusableSchemas<IPageMetadata>(
    schemaNames,
    new RetrievePagesOfReusableSchemasParameters(),
    query => query
                // Get the top 20 results
                .TopN(20),
    cacheSettings,
    configureModel: null // Use default mapping (columnName <=> propertyName)
);

RetrievePagesOfReusableSchemasParameters

Property

Default value

Description

ChannelName

null

Name of the website channel to fetch the pages from. If null, the channel from the current request context is used.

PathMatch

null

Limits results based on the content tree path (e.g., children of a path, specific path). If null, no path filtering is used.

IncludeUrlPath

true

Specifies if page URL data should be included in the results. This data is necessary when resolving page URLs and saves a database roundtrip if included.

LinkedItemsMaxLevel

0

Controls the depth of linked content items to retrieve recursively along with the main page. A value of 0 means no linked items are retrieved.

LanguageName

null

Allows you to override the default content language determined by the current context. If left null, the language retrieved from the current HTTP request is used.

UseLanguageFallbacks

true

Determines if the system should attempt to retrieve content in fallback languages if the content is not available in the primary specified language.

IncludeSecuredItems

false

Specifies whether content items requiring special permissions (e.g., secured sections) should be included in the results.

IsForPreview

null

Allows overriding the preview mode context. If left null, the retrieval respects the current website context (whether the request is in preview mode or live). Set to true to force preview data or false to force live data.

Retrieve pages of a single content type

Method: RetrievePages<TSource, TResult>(...)

Retrieves a collection of pages of a specific content type, represented by the TResult generic. Allows filtering by path, language, and other criteria using RetrievePagesParameters. The provided TSource type determines the content type to retrieve. It must be a model class registered using RegisterContentTypeMapping (applied to generated system classes by default). For this method, TSource also serves as the intermediate mapped result provided to the configureModel delegate.

C#
Basic usage


// Assuming 'NewsArticle' is a generated model class for your news pages
// Gets all news articles using default settings (language, preview context, etc.)
IEnumerable<NewsArticle> newsArticles =
  await contentRetriever.RetrievePages<NewsArticle>();

C#
With parameters


// Retrieve news articles under the /news path, including one level of linked items
var parameters = new RetrievePagesParameters
{
    // Retrieve only children under the specified path
    PathMatch = PathMatch.Children("/news"),
    // Include directly linked items
    LinkedItemsMaxLevel = 1
};

IEnumerable<NewsArticle> newsArticles =
  await contentRetriever.RetrievePages<NewsArticle>(parameters);

C#
All configuration options


// Assuming NewsArticleSummary is a simpler model
public class NewsArticleSummary
{
    public string Title { get; set; }
    public string Summary { get; set; }
}

// Retrieve the top 5 latest news articles under /news, only getting specific columns
var parameters = new RetrievePagesParameters
{
    PathMatch = PathMatch.Children("/news")
};

// Disable caching
var cacheSettings = RetrievalCacheSettings.CacheDisabled;

// NewsArticle is `TSource`, avalilable in configureModel
// NewsArticleSummary is `TResult`, the final type returned by the call
IEnumerable<NewsArticle> latestNews =
  await contentRetriever.RetrievePages<NewsArticle, NewsArticleSummary>(
    parameters,
    query => query
                .Columns("Headline", "PublicationDate", "Summary") // Select specific columns
                .OrderByDescending("PublicationDate") // Order by date
                .TopN(5), // Get the top 5
    cacheSettings,
    configureModel: async (container, source) => new NewsArticleSummary
    {
        // Source is 'NewsArticle'
        Title = $"{source.Headline} - #{source.PublicationDate.ToString("en-US")}",
        Summary = source.Summary
    }
);

RetrievePagesParameters

Property

Default value

Description

ChannelName

null

Name of the website channel to fetch the pages from. If null, the channel from the current request context is used.

PathMatch

null

Limits results based on the content tree path (e.g., children of a path, specific path). If null, no path filtering is used.

IncludeUrlPath

true

Specifies if page URL data should be included in the results. This data is necessary when resolving page URLs and saves a database roundtrip if included.

LinkedItemsMaxLevel

0

Controls the depth of linked content items to retrieve recursively along with the main page. A value of 0 means no linked items are retrieved.

LanguageName

null

Allows you to override the default content language determined by the current context. If left null, the language retrieved from the current HTTP request is used.

UseLanguageFallbacks

true

Determines if the system should attempt to retrieve content in fallback languages if the content is not available in the primary specified language.

IncludeSecuredItems

false

Specifies whether content items requiring special permissions (e.g., secured sections) should be included in the results.

IsForPreview

null

Allows overriding the preview mode context. If left null, the retrieval respects the current website context (whether the request is in preview mode or live). Set to true to force preview data or false to force live data.

Retrieve pages of multiple content types

Method: RetrievePagesOfContentTypes<TResult>(...)

Description: Retrieves a collection of web pages belonging to one of the specified content type code names, mapping them to the TResult model. Allows filtering by path, language, and other criteria using RetrievePagesOfContentTypesParameters.

C#
Basic usage


var contentTypes = new[] { Article.CONTENT_TYPE_NAME, Blog.CONTENT_TYPE_NAME };

// Gets all articles and blogs using default settings
// Assuming 'BaseViewModel' is a suitable base class or interface
// You can also use 'IWebPageFieldsSource' as the shared type
// Suitable model classes are paired with content types using
// 'RegisterContentTypeMappingAttribute' (automatically added to generated classes)
IEnumerable<BaseViewModel> pages =
  await contentRetriever.RetrievePagesOfContentTypes<BaseViewModel>(contentTypes);

// Use pattern matching to handle the specific type
switch (allPages.FirstOrDefault())
{
  case Article article:
    // Specific logic for ArticlePage
    Console.WriteLine($"Displaying Article: {article.Title}");
    // Render article view...
    break;

  case Blog blog:
    // Specific logic for LandingPage
    Console.WriteLine($"Displaying Landing Page: {blog.Headline}");
    // Render landing page view...
    break;

  default:
    // Handle any other unexpected page types
    // Render a default view...
    break;
}

C#
With parameters


var contentTypes = new[] { Article.CONTENT_TYPE_NAME, Blog.CONTENT_TYPE_NAME };

// Retrieve articles and blogs under the /archive path
var parameters = new RetrievePagesOfContentTypesParameters
{
    PathMatch = PathMatch.Children("/archive")
};

IEnumerable<BaseViewModel> archivePages =
  await contentRetriever.RetrievePagesOfContentTypes<BaseViewModel>(contentTypes, parameters);

C#
All configuration options


var contentTypes = new[] { Article.CONTENT_TYPE_NAME, Blog.CONTENT_TYPE_NAME };

// Retrieve the first 10 articles or blogs under /archive, ordered by name
var parameters = new RetrievePagesOfContentTypesParameters
{
    PathMatch = PathMatch.Children("/archive")
};

// Disable caching
var cacheSettings = RetrievalCacheSettings.CacheDisabled;

// Assuming BaseViewModel is a suitable base class
IEnumerable<BaseViewModel> links = await contentRetriever.RetrievePagesOfContentTypes<BaseViewModel>(
    contentTypes,
    parameters,
    query => query
                .OrderBy("DocumentName") // Order by name
                .TopN(10), // Get the top 10
    cacheSettings,
    configureModel: null // Use default mapping
);

RetrievePagesOfContentTypesParameters

Property

Default value

Description

ChannelName

null

Name of the website channel to fetch the pages from. If null, the channel from the current request context is used.

PathMatch

null

Limits results based on the content tree path (e.g., children of a path, specific path). If null, no path filtering is used.

IncludeUrlPath

true

Specifies if page URL data should be included in the results. This data is necessary when resolving page URLs and saves a database roundtrip if included.

LinkedItemsMaxLevel

0

Controls the depth of linked content items to retrieve recursively along with the main page. A value of 0 means no linked items are retrieved.

LanguageName

null

Allows you to override the default content language determined by the current context. If left null, the language retrieved from the current HTTP request is used.

UseLanguageFallbacks

true

Determines if the system should attempt to retrieve content in fallback languages if the content is not available in the primary specified language.

IncludeSecuredItems

false

Specifies whether content items requiring special permissions (e.g., secured sections) should be included in the results.

IsForPreview

null

Allows overriding the preview mode context. If left null, the retrieval respects the current website context (whether the request is in preview mode or live). Set to true to force preview data or false to force live data.

Retrieve all pages

Method: RetrieveAllPages<TSource, TResult>(...)

Retrieves all pages (by default from the current channel), mapping them to the specified TResult model. Allows filtering by path, language, and other criteria using RetrieveAllPagesParameters.

C#
Basic usage


// Assuming 'BasePageViewModel' is a suitable base class for all pages
// Gets all pages using default settings
IEnumerable<BasePageViewModel> allPages =
  await contentRetriever.RetrieveAllPages<BasePageViewModel>();

// Use pattern matching to handle the specific type
switch (allPages.FirstOrDefault())
{
  case ArticlePage article:
    // Specific logic for ArticlePage
    Console.WriteLine($"Displaying Article: {article.Title}");
    // Render article view...
    break;

  case LandingPage landing:
    // Specific logic for LandingPage
    Console.WriteLine($"Displaying Landing Page: {landing.Headline}");
    // Render landing page view...
    break;

  case null:
    // Handle case where the page is not found or not retrievable
    Console.WriteLine("Current page not found.");
    // Render 404 view...
    break;

  default:
    // Handle any other unexpected page types
    // Render a default view...
    break;
}

C#
With parameters


var parameters = new RetrieveAllPagesParameters() {
  ChannelName = "FrenchCuisine"
};

IEnumerable<BasePageViewModel> allLivePages =
  await contentRetriever.RetrieveAllPages<BasePageViewModel>(parameters);

C#
All configuration options


// Retrieve all pages under '/Articles', getting only specific columns
var parameters = new RetrieveAllPagesParameters
{
  PathMatch = PathMatch.Section("/Articles")
};

// Disable caching
var cacheSettings = RetrievalCacheSettings.CacheDisabled;

// Assuming Article is a generated model class
IEnumerable<PageTitleModel> pageLinks =
  await contentRetriever.RetrieveAllPages<BasePageViewModel>(
    parameters,
    query => query
                .Columns("PageTitle")
    cacheSettings,
    configureModel: async (container, baseModel) => {
      // Retrieve only the title and map to specific model
      return new PageTitleModel() {
        PageTitle = baseModel.PageTitle ?? "Untitled page"
      }
    } 
);

RetrieveAllPagesParameters

Some overloads of RetrievePages require an instance of RetrieveAllPagesParameters. This object allows you to fine-tune how the pages are retrieved.

Property

Default value

Description

ChannelName

null

Name of the website channel to fetch the pages from. If null, the channel from the current request context is used.

PathMatch

null

Limits results based on the content tree path (e.g., children of a path, specific path). If null, no path filtering is used.

IncludeUrlPath

true

Specifies if page URL data should be included in the results. This data is necessary when resolving page URLs and saves a database roundtrip if included.

LinkedItemsMaxLevel

0

Controls the depth of linked content items to retrieve recursively along with the main page. A value of 0 means no linked items are retrieved.

LanguageName

null

Allows you to override the default content language determined by the current context. If left null, the language retrieved from the current HTTP request is used.

UseLanguageFallbacks

true

Determines if the system should attempt to retrieve content in fallback languages if the content is not available in the primary specified language.

IncludeSecuredItems

false

Specifies whether content items requiring special permissions (e.g., secured sections) should be included in the results.

IsForPreview

null

Allows overriding the preview mode context. If left null, the retrieval respects the current website context (whether the request is in preview mode or live). Set to true to force preview data or false to force live data.

Content item queries

Retrieve content items sharing reusable field schema

Method: RetrieveContentOfReusableSchemas<TResult>(...)

Retrieves a collection of reusable content items whose content types use one or more of the specified reusable field schemas, mapping them to the TResult model. Allows filtering by workspace, language, and other criteria using RetrieveContentOfReusableSchemasParameters.

C#
Basic usage


// Assuming 'IContactDetails' is an interface implemented by types using the 'ContactSchema'
var schemaNames = new[] { IContactSchema.REUSABLE_FIELD_SCHEMA_NAME };

// Gets all content items using the 'IContactSchema' generated schema interface
IEnumerable<IContactSchema> contacts =
  await contentRetriever.RetrieveContentOfReusableSchemas<IContactSchema>(schemaNames);

C#
With parameters


var schemaNames = new[] { IAddressSchema.REUSABLE_FIELD_SCHEMA_NAME,
                          ILocationSchema.REUSABLE_FIELD_SCHEMA_NAME };

// Retrieve items using Address or Location schemas from the 'Locations' workspace
var parameters = new RetrieveContentOfReusableSchemasParameters
{
    WorkspaceNames = new[] { "Locations" }
};

// Using 'IContentItemFieldsSource' as the shared type
IEnumerable<IContentItemFieldsSource> locationData =
  await contentRetriever
    .RetrieveContentOfReusableSchemas<IContentItemFieldsSource>(schemaNames, parameters);

C#
All configuration options


var schemaNames = new[] { IMetadataSchema.REUSABLE_FIELD_SCHEMA_NAME };

// Disable caching
var cacheSettings = RetrievalCacheSettings.CacheDisabled;

// Assuming IMetadata is an inteface generated for 'MetadataSchema'
IEnumerable<IMetadata> oldestMetadataItems =
  await contentRetriever.RetrieveContentOfReusableSchemas<IMetadata>(
    schemaNames,
    parameters,
    query => query
                // Get the first 5
                .TopN(5),
    cacheSettings,
    configureModel: null // Use default mapping
);

RetrieveContentOfReusableSchemasParameters

Property

Default value

Description

IncludeUrlPath

true

Specifies if page URL data should be included in the results. This data is necessary when resolving page URLs and saves a database roundtrip if included.

WorkspaceNames

[] (Empty Enumerable)

Names of the workspaces from which content should be retrieved.

LinkedItemsMaxLevel

0

Controls the depth of linked content items to retrieve recursively. 0 means no linked items are retrieved.

LanguageName

null

Allows you to override the default content language determined by the current context. If left null, the language retrieved from the current HTTP request is used.

UseLanguageFallbacks

true

Determines if the system should attempt to retrieve content in fallback languages if the content is not available in the primary specified language.

IncludeSecuredItems

false

Specifies whether content items requiring special permissions (e.g., secured sections) should be included in the results.

IsForPreview

null

Allows overriding the preview mode context. If left null, the retrieval respects the current website context (whether the request is in preview mode or live). Set to true to force preview data or false to force live data.

Retrieve content items of a single content type

Method: RetrieveContent<TSource, TResult>(...)

Retrieves a collection of content items of a specific content type, mapped to the TResult model. Allows filtering by workspace, language, and other criteria using RetrieveContentParameters. The provided TSource type determines the content type to retrieve. It must be a model class registered using RegisterContentTypeMapping (applied to generated system classes by default). For this method, TSource also serves as the intermediate mapped result provided to the configureModel delegate.

C#
Basic usage


// Assuming 'Author' is a generated model class for your author content items
// Gets all authors using default settings (language, preview context, etc.)
IEnumerable<Author> authors =
  await contentRetriever.RetrieveContent<Author>();

C#
With parameters


// Retrieve authors from a specific workspace
var parameters = new RetrieveContentParameters
{
    WorkspaceNames = new[] { "BlogContent" }, // Specify relevant workspace
};

IEnumerable<Author> blogAuthors =
  await contentRetriever.RetrieveContent<Author>(parameters);

C#
All configuration options


// Retrieve the top 5 authors with the most articles from the 'BlogContent' workspace
var parameters = new RetrieveContentParameters
{
     WorkspaceNames = new[] { "BlogContent" }
};

// Disable caching
var cacheSettings = RetrievalCacheSettings.CacheDisabled;

// Assuming AuthorSummary is a simpler model with FullName and ArticleCount
public class AuthorSummary
{
    public string FullName { get; set; }
    public int ArticleCount { get; set; }
}

// 'TSource' set to generated model class 'Author'
// Final result `TResult` transformed and mapped to 'AuthorSummary'
IEnumerable<AuthorSummary> topAuthors = await contentRetriever.RetrieveContent<Author, AuthorSummary>(
    parameters,
    query => query
                // Select specific columns
                .Columns("FirstName", "LastName", "ArticleCount")
                // Order by count
                .OrderBy(new OrderByColumn("ArticleCount", OrderDirection.Descending))
                // Get the top 5
                .TopN(5),
    cacheSettings,
    // Example of custom mapping
    async (container, source) => new AuthorSummary
    {
        // Source is 'Author'
        FullName = $"{source.FirstName} {source.LastName}",
        ArticleCount = source.ArticleCount
    }
);

RetrieveContentParameters

Property

Default value

Description

WorkspaceNames

[] (Empty Enumerable)

Names of the workspaces from which content should be retrieved.

LinkedItemsMaxLevel

0

Controls the depth of linked content items to retrieve recursively. 0 means no linked items are retrieved.

LanguageName

null

Allows you to override the default content language determined by the current context. If left null, the language retrieved from the current HTTP request is used.

UseLanguageFallbacks

true

Determines if the system should attempt to retrieve content in fallback languages if the content is not available in the primary specified language.

IncludeSecuredItems

false

Specifies whether content items requiring special permissions (e.g., secured sections) should be included in the results.

IsForPreview

null

Allows overriding the preview mode context. If left null, the retrieval respects the current website context (whether the request is in preview mode or live). Set to true to force preview data or false to force live data.

Retrieve content items of multiple content types

Method: RetrieveContentOfContentTypes<TResult>(...)

Retrieves a collection of reusable content items belonging to the specified content types, mapping them to the TResult model. Allows filtering by workspace, language, and other criteria using RetrieveContentOfContentTypesParameters.

C#
Basic usage


var contentTypes = new[] { Author.CONTENT_TYPE_NAME, Article.CONTENT_TYPE_NAME };

// Gets all authors and articles using default settings
// Uses 'IContentItemFieldsSource' as the shared type.
// Suitable model classes are paired with content types using
// 'RegisterContentTypeMappingAttribute' (automatically added to generated classes)
IEnumerable<IContentItemFieldsSource> blogItems =
  await contentRetriever
    .RetrieveContentOfContentTypes<IContentItemFieldsSource>(contentTypes);

foreach (var item in blogItems)
{
  switch (item)
  {
    case Author author:
      // Handle Author specific logic
      Console.WriteLine($"- Found Author: {author.DisplayName}");
      // e.g., DisplayAuthorBio(author);
      break;

    case Article article:
      // Handle Article specific logic
      Console.WriteLine($"- Found Article: {article.DisplayName}");
      // e.g., DisplayArticleSummary(article);
      break;

    default:
      break;
  }
}

C#
With parameters


var contentTypes = new[] { Author.CONTENT_TYPE_NAME, BookReview.CONTENT_TYPE_NAME };

// Retrieve authors and book reviews from the 'Reviews' workspace
var parameters = new RetrieveContentOfContentTypesParameters
{
    WorkspaceNames = new[] { "Reviews" }
};

IEnumerable<IContentItemFieldsSource> reviewContent =
  // Can use 'IContentItemFieldsSource' if no common base type
  await contentRetriever
    .RetrieveContentOfContentTypes<IContentItemFieldsSource>(contentTypes, parameters);

C#
All configuration options


var contentTypes = new[] { Author.CONTENT_TYPE_NAME,
                           Article.CONTENT_TYPE_NAME,
                           Book.CONTENT_TYPE_NAME };

// Retrieve the 10 most recently modified authors, articles, or books
var parameters = new RetrieveContentOfContentTypesParameters
{
     WorkspaceNames = new[] { "MainContent", "BlogContent" } // Search multiple workspaces
};

// Disable caching
var cacheSettings = RetrievalCacheSettings.CacheDisabled;

// Assuming IContentInfo is an interface with Name and LastModified properties
IEnumerable<IContentInfo> recentContent =
  await contentRetriever.RetrieveContentOfContentTypes<IContentInfo>(
    contentTypes,
    parameters,
    query => query
                // Select specific columns
                .Columns("DisplayName", "ContentItemModifiedWhen")
                // Get the top 10
                .TopN(10),
    cacheSettings,
    configureModel: null // Use default mapping
);

RetrieveContentOfContentTypesParameters

Property

Default value

Description

IncludeUrlPath

true

Specifies if page URL data should be included in the results. This data is necessary when resolving page URLs and saves a database roundtrip if included.

WorkspaceNames

[] (Empty Enumerable)

Names of the workspaces from which content should be retrieved.

LinkedItemsMaxLevel

0

Controls the depth of linked content items to retrieve recursively. 0 means no linked items are retrieved.

LanguageName

null

Allows you to override the default content language determined by the current context. If left null, the language retrieved from the current HTTP request is used.

UseLanguageFallbacks

true

Determines if the system should attempt to retrieve content in fallback languages if the content is not available in the primary specified language.

IncludeSecuredItems

false

Specifies whether content items requiring special permissions (e.g., secured sections) should be included in the results.

IsForPreview

null

Allows overriding the preview mode context. If left null, the retrieval respects the current website context (whether the request is in preview mode or live). Set to true to force preview data or false to force live data.