AFElement.FindElements Method (AFDatabase, AFElement, String, AFSearchField, Boolean, AFSortField, AFSortOrder, Int32)
- Last UpdatedSep 18, 2024
- PI System
- AF SDK 2024
- Developer
Performs a non-paged text search within the AFDatabase to retrieve a collection
of AFElement objects which have a field that matches the specified query string.
Namespace: OSIsoft.AF.Asset
Assembly: OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.0.1156
Syntax
public static AFNamedCollectionList<AFElement> FindElements( AFDatabase database, AFElement searchRoot, string query, AFSearchField field, bool searchFullHierarchy, AFSortField sortField, AFSortOrder sortOrder, int maxCount )
Public Shared Function FindElements ( database As AFDatabase, searchRoot As AFElement, query As String, field As AFSearchField, searchFullHierarchy As Boolean, sortField As AFSortField, sortOrder As AFSortOrder, maxCount As Integer ) As AFNamedCollectionList(Of AFElement) Dim database As AFDatabase Dim searchRoot As AFElement Dim query As String Dim field As AFSearchField Dim searchFullHierarchy As Boolean Dim sortField As AFSortField Dim sortOrder As AFSortOrder Dim maxCount As Integer Dim returnValue As AFNamedCollectionList(Of AFElement) returnValue = AFElement.FindElements(database, searchRoot, query, field, searchFullHierarchy, sortField, sortOrder, maxCount)
public: static AFNamedCollectionList<AFElement^>^ FindElements( AFDatabase^ database, AFElement^ searchRoot, String^ query, AFSearchField field, bool searchFullHierarchy, AFSortField sortField, AFSortOrder sortOrder, int maxCount )
static member FindElements : database : AFDatabase * searchRoot : AFElement * query : string * field : AFSearchField * searchFullHierarchy : bool * sortField : AFSortField * sortOrder : AFSortOrder * maxCount : int -> AFNamedCollectionList<AFElement>
Parameters
- database
- Type: OSIsoft.AF.AFDatabase
The AFDatabase to search for the requested objects. - searchRoot
- Type: OSIsoft.AF.Asset.AFElement
The root object to start the search. If null, then the search starts at the AFDatabase. - query
- Type: System.String
The query string used for finding objects.The query string (or match pattern) can include regular characters and wildcard characters. Regular characters must match exactly the characters specified in the query string. Wildcard characters can be matched with arbitrary fragments of the query string. Wildcard characters can be escaped using the single backslash (\) character. Use a double backslash (\\) to match a single backslash. The syntax of the query string has the following rules:
- If null or empty string, then everything will be matched.
- If no wildcards, then an exact match on the query string is performed.
- Wildcard * can be placed anywhere in the query string and matches zero or more characters.
- Wildcard ? can be placed anywhere in the query string and matches exactly one character.
- One character in a set of characters are matched by placing them within [ ]. For example, a[bc] would match 'ab' or 'ac', but it would not match 'ad' or 'abd'.
- One character in a set of characters are not matched by placing them within [! ]. For example, a[!bc] would match 'ad', but it would not match 'ab', 'ac', or 'abd'.
- A character in a range of characters from first to last are matched using the following syntax: [first - last]. For example, a[a-c] would match 'aa', 'ab', or 'ac', but it would not match 'ad' or 'abc'.
- field
- Type: OSIsoft.AF.AFSearchField
Specifies which of the object's properties are searched. - searchFullHierarchy
- Type: System.Boolean
Specifies if the search should include objects nested further than the immediate children of the searchRoot. - sortField
- Type: OSIsoft.AF.AFSortField
The field or property of the object used to sort the returned collection. - sortOrder
- Type: OSIsoft.AF.AFSortOrder
The order that the returned collection is sorted. - maxCount
- Type: System.Int32
The maximum number of objects to be returned.
Return Value
Type: AFNamedCollectionList<AFElement>Returns a collection containing the first page of AFElement objects which match the specified query string.
Remarks
An object matches the search if the specified query is found in one of the object's properties specified by the field parameter.
![]() |
---|
If a searchRoot is specified and the searchFullHierarchy parameter is true, then any added or removed element references that have not been checked in will be ignored when searching the hierarchy. |
![]() |
---|
Consider using the new AFElementSearch class for finding elements instead of using this method. |