Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AF SDK Reference

AFElement.FindElementsByCategory Method (AFDatabase, AFElement, AFCategory, Boolean, AFSortField, AFSortOrder, Int32, Int32, Int32)

AFElement.FindElementsByCategory Method (AFDatabase, AFElement, AFCategory, Boolean, AFSortField, AFSortOrder, Int32, Int32, Int32)

  • Last UpdatedNov 18, 2025
  • 5 minute read
AFElement.FindElementsByCategory Method (AFDatabase, AFElement, AFCategory, Boolean, AFSortField, AFSortOrder, Int32, Int32, Int32)

Note: This API is now obsolete.

Retrieves a paged collection of AFElement objects that have the specified AFCategory defined for the element.

Namespace:  OSIsoft.AF.Asset
Assembly:  OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182

Syntax

[BrowsableAttribute(false)]
[ObsoleteAttribute("This method has been replaced by the 'AFElementSearch' class using the 'Root' and 'Category' filters.")]
public static AFNamedCollectionList<AFElement> FindElementsByCategory(
	AFDatabase database,
	AFElement searchRoot,
	AFCategory category,
	bool searchFullHierarchy,
	AFSortField sortField,
	AFSortOrder sortOrder,
	int startIndex,
	int maxCount,
	out int totalCount
)
<BrowsableAttribute(false)>
<ObsoleteAttribute("This method has been replaced by the 'AFElementSearch' class using the 'Root' and 'Category' filters.")>
Public Shared Function FindElementsByCategory ( 
	database As AFDatabase,
	searchRoot As AFElement,
	category As AFCategory,
	searchFullHierarchy As Boolean,
	sortField As AFSortField,
	sortOrder As AFSortOrder,
	startIndex As Integer,
	maxCount As Integer,
	<OutAttribute> ByRef totalCount As Integer
) As AFNamedCollectionList(Of AFElement)

Dim database As AFDatabase
Dim searchRoot As AFElement
Dim category As AFCategory
Dim searchFullHierarchy As Boolean
Dim sortField As AFSortField
Dim sortOrder As AFSortOrder
Dim startIndex As Integer
Dim maxCount As Integer
Dim totalCount As Integer
Dim returnValue As AFNamedCollectionList(Of AFElement)

returnValue = AFElement.FindElementsByCategory(database, 
	searchRoot, category, searchFullHierarchy, 
	sortField, sortOrder, startIndex, 
	maxCount, totalCount)
public:
[BrowsableAttribute(false)]
[ObsoleteAttribute(L"This method has been replaced by the 'AFElementSearch' class using the 'Root' and 'Category' filters.")]
static AFNamedCollectionList<AFElement^>^ FindElementsByCategory(
	AFDatabase^ database, 
	AFElement^ searchRoot, 
	AFCategory^ category, 
	bool searchFullHierarchy, 
	AFSortField sortField, 
	AFSortOrder sortOrder, 
	int startIndex, 
	int maxCount, 
	[OutAttribute] int% totalCount
)
[<BrowsableAttribute(false)>]
[<ObsoleteAttribute("This method has been replaced by the 'AFElementSearch' class using the 'Root' and 'Category' filters.")>]
static member FindElementsByCategory : 
        database : AFDatabase * 
        searchRoot : AFElement * 
        category : AFCategory * 
        searchFullHierarchy : bool * 
        sortField : AFSortField * 
        sortOrder : AFSortOrder * 
        startIndex : int * 
        maxCount : int * 
        totalCount : int byref -> AFNamedCollectionList<AFElement> 

Parameters

database
Type: OSIsoft.AFAFDatabase
The AFDatabase to search for the requested objects.
searchRoot
Type: OSIsoft.AF.AssetAFElement
The root object to start the search. If , then the search starts at the AFDatabase.
category
Type: OSIsoft.AFAFCategory
The AFCategory that an AFElement must have defined to be included in the returned list. If , then all elements without any category will be returned.
searchFullHierarchy
Type: SystemBoolean
Specifies if the search should include objects nested further than the immediate children of the searchRoot.
sortField
Type: OSIsoft.AFAFSortField
The field or property of the object used to sort the returned collection. This value should not be changed between calls when attempting to get the next page of items.
sortOrder
Type: OSIsoft.AFAFSortOrder
The order that the returned collection is sorted. This value should not be changed between calls when attempting to get the next page of items.
startIndex
Type: SystemInt32
The starting index (zero based) of the items to be returned.
maxCount
Type: SystemInt32
The maximum number of objects to be returned per call (the page size).
totalCount
Type: SystemInt32
The total number of objects that match the search criteria.

Return Value

Type: AFNamedCollectionListAFElement
Returns a collection containing the first page of AFElement objects that have the specified AFCategory defined for the element under the searchRoot element or the database.

Remarks

This method will return the elements that have the specified refCategory defined under the specified searchRoot element or the database. If the searchRoot is specified, then its QueryDate will be used to determine the collection of elements that are returned. Otherwise, the QueryDate of the database will be used.

Note Notes to Callers
If a searchRoot is specified and the searchFullHierarchy parameter is , then any added or removed element references that have not been checked in will be ignored when searching the hierarchy.

Important note Important
Consider using the new AFElementSearch class for finding elements instead of using this method.

Version Information

AFSDK

Supported in: 2.8.5, 2.8, 2.7.5, 2.7, 2.6, 2.5, 2.4
Obsolete (compiler warning) in 3.1.1
Obsolete (compiler warning) in 3.1.0
Obsolete (compiler warning) in 3.0.2
Obsolete (compiler warning) in 3.0.1
Obsolete (compiler warning) in 3.0.0
Obsolete (compiler warning) in 2.10.11
Obsolete (compiler warning) in 2.10.5
Obsolete (compiler warning) in 2.10.0
Obsolete (compiler warning) in 2.10
Obsolete (compiler warning) in 2.9.5
Obsolete (compiler warning) in 2.9

See Also

In This Topic
TitleResults for “How to create a CRG?”Also Available in