CompoundCriteriaItem

The CompoundCriteriaItem class represents a compound criteria item used in Criteria. A compound criteria item allows you to combine multiple criteria items using a logical operator, AND or OR.

Inheritance: CriteriaItem

Implements: IAdmCompoundCriteriaItem

Namespace: Softerra.Adaxes.Directory.Criteria

Methods

Properties

  • Property

  • Description

  • Items

  • Gets the list of all nested criteria items.

Details

Add(CriteriaItem)

Adds a nested criteria item to this compound criteria item.

CompoundCriteriaItem Add(CriteriaItem item)

Parameters

The item parameter specifies the criteria item to add. It is possible to add the following items:

Return value

The method returns this instance of CompoundCriteriaItem after updating it.

Examples

The following code sample adds nested criteria items to a compound criteria item.

PowerShell
$criteria = YOUR-CRITERIA

# Create simple criteria items.
$item1 = $criteria.CreateSimple()
$item2 = $criteria.CreateSimple()

# Add the items to a compound criteria.
$compoundItem = $criteria.CreateCompound()
$compoundItem.Add($item1).Add($item2)
C#
using Softerra.Adaxes.Directory.Criteria;

class Program
{
    public static void Main()
    {
        criteria = <YOUR-CRITERIA>

        // Create simple criteria items.
        SimpleCriteriaItem item1 = new();
        SimpleCriteriaItem item2 = new();

        // Add the items to a compound criteria.
        CompoundCriteriaItem compoundItem = new();
        compoundItem.Add(item1).Add(item2);
    }
}

Add(string)

Creates a new criteria item from a Criteria expression, and adds it to this compound criteria item.

CompoundCriteriaItem Add(string item)

Parameters

The item parameter specifies the Criteria expression. For details, see How to build criteria.

Return value

The method returns this instance of CompoundCriteriaItem after updating it.

Examples

The following code sample creates Criteria using expressions.

PowerShell
$criteria = YOUR-CRITERIA

# Create new criteria for the Group object type.
$criteria.AddType("group")
$criteria["group"].Add({description -startswith "My"})
C#
// Criteria expressions can be used in PowerShell only.

GetItem()

Gets a nested criteria item by index.

CriteriaItem GetItem(int index)

RemoveItem()

Removes a nested criteria item by index.

CompoundCriteriaItem RemoveItem(int index)

Return value

The method returns this instance of CompoundCriteriaItem after updating it.


RemoveAllItems()

Removes all nested criteria items.

CompoundCriteriaItem RemoveAllItems()

Return value

The method returns this instance of CompoundCriteriaItem after updating it.


SetLogicalOperator()

Sets the logical operator for evaluating multiple nested criteria items.

CompoundCriteriaItem SetLogicalOperator(LogicalOperator operator)

Return value

The method returns this instance of CompoundCriteriaItem after updating it.

Examples

The following code sample creates Criteria that matches all users whose account is either expired or disabled.

PowerShell
$criteria = YOUR-CRITERIA

# Create new criteria for the User object type.
$criteria.AddType("user")
$criteria["user"].Add({accountDisabled -eq $true}).
    Add({accountExpires -expired $true}).
    SetLogicalOperator("OR")
C#
using Softerra.Adaxes.Directory.Criteria;

class Program
{
    public static void Main()
    {
        criteria = <YOUR-CRITERIA>;

        // Create simple criteria items.
        SimpleCriteriaItem item1 = new()
        {
            Property = "accountDisabled",
            Operator = "eq",
            Values = { true }
        };
        SimpleCriteriaItem item2 = new()
        {
            Property = "accountExpires",
            Operator = "expired",
            Values = { true }
        };

        // Add item to User object type and set logical operator.
        criteria.AddType("user");
        criteria["user"].Add(item1).Add(item2).
            SetLogicalOperator(LogicalOperator.Or);
    }
}

Remarks

The default logical operator of a new CompoundCriteriaItem is AND.


Items

Gets the list of all nested criteria items.

  • Type:
  • IList<CriteriaItem>
  • Access:
  • Read-only

Requirements

Minimum required version: 2023

See also