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

AF SDK Reference

AFElement.LoadElementsToDepth Method

  • Last UpdatedNov 18, 2025
  • 3 minute read
AFElement.LoadElementsToDepth Method
Loads the specified list AFElement objects and their child elements to the hierarchical depth specified.

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

Syntax

public static AFNamedCollectionList<AFElement> LoadElementsToDepth(
	IList<AFElement> elements,
	bool fullLoad,
	int depth,
	int maxCount
)
Public Shared Function LoadElementsToDepth ( 
	elements As IList(Of AFElement),
	fullLoad As Boolean,
	depth As Integer,
	maxCount As Integer
) As AFNamedCollectionList(Of AFElement)

Dim elements As IList(Of AFElement)
Dim fullLoad As Boolean
Dim depth As Integer
Dim maxCount As Integer
Dim returnValue As AFNamedCollectionList(Of AFElement)

returnValue = AFElement.LoadElementsToDepth(elements, 
	fullLoad, depth, maxCount)
public:
static AFNamedCollectionList<AFElement^>^ LoadElementsToDepth(
	IList<AFElement^>^ elements, 
	bool fullLoad, 
	int depth, 
	int maxCount
)
static member LoadElementsToDepth : 
        elements : IList<AFElement> * 
        fullLoad : bool * 
        depth : int * 
        maxCount : int -> AFNamedCollectionList<AFElement> 

Parameters

elements
Type: System.Collections.GenericIListAFElement
The list of root elements to be loaded. If , then this method does nothing. All elements in the list must be from the same PISystem and have the same QueryDate.
fullLoad
Type: SystemBoolean
Specifies whether the elements should be fully loaded. To only load a specific set of AFAttributes of the elements, specify and then use the LoadAttributes method to load those particular attributes. Note that if the elements are not fully loaded, then traversing the hierarchy via the Elements property will cause a reload of the element on access.
depth
Type: SystemInt32
Specifies the number of levels of the element hierarchy to load past the level of the elements in the collection passed in. For example, a depth parameter of 2 would indicate that all child elements and grandchild elements of the specified elements would be loaded.
maxCount
Type: SystemInt32
Specifies the maximum number of objects to load. Once the maximum number of objects is reached, the load will terminate.

Return Value

Type: AFNamedCollectionListAFElement
The list of elements returned is a list of all child elements loaded at all depths. Even though each AFElement in the elements list are loaded, they are not included in the returned list.

Remarks

This method can be used to significantly decrease the time for loading a portion of the element hierarchy starting with the AFElement objects in the specified list. Each AFElement in the list will be loaded along with their children from the server into the client. This method can also be used to partially load the elements with only the needed attributes to reduce memory by specifying for the fullLoad parameter and then using the LoadAttributes method.

Examples

See the Loading Element Hierarchy example which illustrates using this method to bulk load an entire hierarchy of elements into the client. See the Loading Partial Elements example which illustrates partially loading elements in bulk into the client.

Version Information

AFSDK


See Also

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