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

AF SDK Reference

AFSearch(T).FindObjects Method

  • Last UpdatedNov 18, 2025
  • 6 minute read
AFSearch(T).FindObjects Method
This method will return the objects that match the search tokens.

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

Syntax

public IEnumerable<T> FindObjects(
	int startIndex = 0,
	bool fullLoad = false,
	int pageSize = 0
)
Public Function FindObjects ( 
	Optional startIndex As Integer = 0,
	Optional fullLoad As Boolean = false,
	Optional pageSize As Integer = 0
) As IEnumerable(Of T)

Dim instance As AFSearch
Dim startIndex As Integer
Dim fullLoad As Boolean
Dim pageSize As Integer
Dim returnValue As IEnumerable(Of T)

returnValue = instance.FindObjects(startIndex, 
	fullLoad, pageSize)
public:
virtual IEnumerable<T>^ FindObjects(
	int startIndex = 0, 
	bool fullLoad = false, 
	int pageSize = 0
) sealed
abstract FindObjects : 
        ?startIndex : int * 
        ?fullLoad : bool * 
        ?pageSize : int 
(* Defaults:
        let _startIndex = defaultArg startIndex 0
        let _fullLoad = defaultArg fullLoad false
        let _pageSize = defaultArg pageSize 0
*)
-> IEnumerable<'T> 
override FindObjects : 
        ?startIndex : int * 
        ?fullLoad : bool * 
        ?pageSize : int 
(* Defaults:
        let _startIndex = defaultArg startIndex 0
        let _fullLoad = defaultArg fullLoad false
        let _pageSize = defaultArg pageSize 0
*)
-> IEnumerable<'T> 

Parameters

startIndex (Optional)
Type: SystemInt32
The starting index (zero based) of the items to be returned.
fullLoad (Optional)
Type: SystemBoolean
If , then the returned objects will be full loaded. If , then the returned objects may not be fully loaded and will require another call to the server if additional information about the object is requested that is not already loaded.
pageSize (Optional)
Type: SystemInt32
The page size used for retrieving objects from the server. If this parameter is less than or equal to zero, then the page size will be set to the current value of the CollectionPageSize setting.

Return Value

Type: IEnumerableT
Returns an enumerable list of the objects found using the search tokens for this search object.

Implements

IAFSearchTFindObjects(Int32, Boolean, Int32)

Exceptions

ExceptionCondition
FormatException This exception is thrown if the ThrowOnError property is and there is a format error in the search query.
NotSupportedException This exception is thrown if the ThrowOnError property is and one of the filters is not supported or the query is too complex to be evaluated by the server.

Remarks

This method will search for matching objects based upon the search tokens. By default, attribute values with a data reference are evaluated using the QueryDate of the database. The TimeContext search filter can be used to modify this behavior.

Examples

 1// Get the Database
 2PISystems myPISystems = new PISystems();
 3PISystem myPISystem = myPISystems.DefaultPISystem;
 4if (myPISystem == null)
 5    throw new InvalidOperationException("Default PISystem was not found.");
 6AFDatabase myDB = myPISystem.Databases[dbName];
 7if (myDB == null)
 8    throw new InvalidOperationException("Database was not found.");
 9
10// Create a search to find all the elements in a specific area
11// of a plant (e.g. 'WestPlant\Area32') and have either a 'Valve' category or a name beginning with 'Valve'.
12int count;
13using (var search = new AFElementSearch(myDB, "FindValves", @"Root:'WestPlant\Area32' (Category:'Valve' OR Name:Valve*)"))
14{
15    search.CacheTimeout = TimeSpan.FromMinutes(10);
16
17    // When the elements are returned from a find operation, they are only
18    // partially loaded into memory, typically enough to display their 
19    // inherent properties, such as Name, Description, Template, Type, etc.  
20    // When a piece of information is accessed in the element that requires more 
21    // information, an RPC to the server is made to fully load the element.  
22    // By having the search do a full load, all information is loaded in bulk and
23    // we can reduce the number of RPCs made to retrieve this information.
24    count = search.GetTotalCount();
25    Console.WriteLine("Found {0} Elements.", count);
26    foreach (AFElement item in search.FindObjects(fullLoad: true))
27    {
28        // Now we can use the elements without having to make any additional RPCs
29        // In the example below, accessing the Attributes collection would have 
30        // caused an additional RPC per element found.
31        // Now we can use the elements without having to make any additional RPCs
32        // In the example below, accessing the Attributes collection would have 
33        // caused an additional RPC per element found.
34        Console.WriteLine("  Element {0} has {1} Attributes", item.Name, item.Attributes.Count);
35    }
36}
 1' Get the Database
 2Dim myPISystems As New PISystems()
 3Dim myPISystem As PISystem = myPISystems.DefaultPISystem
 4If myPISystem Is Nothing Then
 5    Throw New InvalidOperationException("Default PISystem was not found.")
 6End If
 7Dim myDB As AFDatabase = myPISystem.Databases(dbName)
 8If myDB Is Nothing Then
 9    Throw New InvalidOperationException("Database was not found.")
10End If
11
12' Create a search to find all the elements in a specific area
13' of a plant (e.g. 'WestPlant\Area32') and have either a 'Valve' or 'Boiler' category.
14Dim count As Integer
15Using search As New AFElementSearch(myDB, "FindValves", "Root:'WestPlant\Area32' (Category:'Valve' OR Name:Valve*)")
16
17    search.CacheTimeout = TimeSpan.FromMinutes(10)
18
19    ' When the elements are returned from a find operation, they are only
20    ' partially loaded into memory, typically enough to display their 
21    ' inherent properties, such as Name, Description, Template, Type, etc.  
22    ' When a piece of information is accessed in the element that requires more 
23    ' information, an RPC to the server is made to fully load the element.  
24    ' By having the search do a full load, all information is loaded in bulk and
25    ' we can reduce the number of RPCs made to retrieve this information.
26    count = search.GetTotalCount()
27    Console.WriteLine("Found {0} Elements.", count)
28    For Each item As AFElement In search.FindObjects(fullLoad:=True)
29
30        ' Now we can use the elements without having to make any additional RPCs
31        ' In the example below, accessing the Attributes collection would have 
32        ' caused an additional RPC per element found.
33        ' Now we can use the elements without having to make any additional RPCs
34        ' In the example below, accessing the Attributes collection would have 
35        ' caused an additional RPC per element found.
36        Console.WriteLine("  Element {0} has {1} Attributes", item.Name, item.Attributes.Count)
37    Next
38End Using

No code example is currently available or this language may not be supported.

No code example is currently available or this language may not be supported.

Version Information

AFSDK

Supported in: 3.1.1, 3.1.0, 3.0.2, 3.0.1, 3.0.0, 2.10.11, 2.10.5

See Also

Reference

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