Query departments

Query a single department by a property

To query a single department, you must perform the following:

  1. Get an instance of the manager.
    Get an instance of the TaxonomyManager object.
  2. Get the Departments taxonomy.
    To get the Departments taxonomy, call the GetTaxonomies method and filter the collection by the title of the taxonomy.
  3. Get the specified department.
    To get the specified department, you must filter the Taxa collection of the taxonomy by the desired criteria.

Use the following code samples to query a single department by name, by title, and by ID:

Query a department by name

Query a department by title

NOTE: Filtering the Taxa collection by title is case-sensitive.

Query a department by ID

Query the departments of a parent department

To query all departments under a specified parent department, you must perform the following:

  1. Get an instance of the manager.
    Get an instance of the TaxonomyManager object.
  2. Get the Departments taxonomy.
    To get the Departments taxonomy, call the GetTaxonomies method and filter the collection by the title of the taxonomy.
  3. Get the departments.
    To get the specified departments, you must filter the Taxa collection of the taxonomy by the name of the parent department.

Use the following code sample:

NOTE: Because the Parent property of the first level of departments is null, you must make a check whether the Parent property is null.

Query all departments

To query all departments, you must perform the following:

  1. Get an instance of the manager.
    Get an instance of the TaxonomyManager object.
  2. Get the Departments taxonomy.
    To get the Departments taxonomy, call the GetTaxonomies method and filter the collection by the title of the taxonomy.
  3. Get the departments.
    To get the departments, you must return the Taxa collection of the Departments taxonomy.

Use the following code sample:

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?

Next article

Modify departments