AFElement.FindElementsByTemplate Method (AFDatabase, AFObject, AFElementTemplate, Boolean, AFSortField, AFSortOrder, Int32, Int32, Int32)
- Last UpdatedNov 18, 2025
- 4 minute read
- PI System
- AF SDK 2024 R2
- Developer
Retrieves a paged collection of AFElement objects that are instantiated from the specified
AFElementTemplate.
Namespace: OSIsoft.AF.Asset
Assembly: OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182
Syntax
public static AFNamedCollectionList<AFElement> FindElementsByTemplate( AFDatabase database, AFObject searchRoot, AFElementTemplate template, bool includeDerived, AFSortField sortField, AFSortOrder sortOrder, int startIndex, int maxCount, out int totalCount )
Public Shared Function FindElementsByTemplate ( database As AFDatabase, searchRoot As AFObject, template As AFElementTemplate, includeDerived 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 AFObject Dim template As AFElementTemplate Dim includeDerived 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.FindElementsByTemplate(database, searchRoot, template, includeDerived, sortField, sortOrder, startIndex, maxCount, totalCount)
public: static AFNamedCollectionList<AFElement^>^ FindElementsByTemplate( AFDatabase^ database, AFObject^ searchRoot, AFElementTemplate^ template, bool includeDerived, AFSortField sortField, AFSortOrder sortOrder, int startIndex, int maxCount, [OutAttribute] int% totalCount )
static member FindElementsByTemplate : database : AFDatabase * searchRoot : AFObject * template : AFElementTemplate * includeDerived : 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.AFAFObject
The root object to start the search (either an AFDatabase, an AFElement, or an AFEventFrame). If specified, then only elements directly owned by the specified object will be returned. If , then all elements with the specified template are returned. - template
- Type: OSIsoft.AF.AssetAFElementTemplate
Specify that the returned elements must have this template or a template derived from this template if includeDerived is . If , then all elements without any template will be returned. - includeDerived
- Type: SystemBoolean
If , then all elements created from this template and any template that is derived from this template will be included in the returned collection. If , then only elements created from this template will be included. If template is , then this parameter is ignored. - 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: AFNamedCollectionListAFElementReturns a collection containing the first page of AFElement objects that are instantiated from the specified AFElementTemplate.
Remarks
This method will return the elements that are instantiated from the specified AFElementTemplate. If a template is specified, then its QueryDate will be used to determine the collection of elements that are returned from this method. Otherwise, the QueryDate of the searchRoot or database will be used.
| Consider using the new AFElementSearch class for finding elements instead of using this method. |