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:

Want to learn more?

Sign up for our free beginner training. Boost your credentials through advanced courses and certification.
Register for Sitefinity training and certification.

Was this article helpful?

Next article

Modify departments