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
-
Method
-
Description
-
Add(CriteriaItem)
-
Adds a nested criteria item.
-
Add(string)
-
Adds a nested criteria item using a Criteria expression.
-
GetItem()
-
Gets a nested criteria item by index.
-
RemoveItem()
-
Removes a nested criteria item by index.
-
RemoveAllItems()
-
Removes all nested criteria items.
-
SetLogicalOperator()
-
Sets the logical operator.
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
- item – 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 { 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
- item – a criteria expression, as a
string. For details on how to build expressions, 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.
$criteria = YOUR-CRITERIA
# Create new criteria for the Group object type.
$criteria.AddType("group")
$criteria["group"].Add({description -startswith "My"})
Remarks
Criteria expressions can only be used in PowerShell.
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)
Parameters
- operator – a logical operator. The default value for a compound criteria item is AND.
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 { 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); } }
Items
Gets the list of all nested criteria items.
- Type:
- IList<CriteriaItem>
- Access:
- Read-only
Requirements
Minimum required version: 2023