AFAttributeSearch.FindAttributes Method
- Last UpdatedNov 18, 2025
- 4 minute read
- PI System
- AF SDK 2024 R2
- Developer
Note: This API is now obsolete.
This method will return the AFAttribute objects that match the
search tokens.
Namespace: OSIsoft.AF.Search
Assembly: OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182
Syntax
[BrowsableAttribute(false)] [ObsoleteAttribute("This method has been replaced by FindObjects.")] public IEnumerable<AFAttribute> FindAttributes( int startIndex = 0, int pageSize = 0 )
<BrowsableAttribute(false)> <ObsoleteAttribute("This method has been replaced by FindObjects.")> Public Function FindAttributes ( Optional startIndex As Integer = 0, Optional pageSize As Integer = 0 ) As IEnumerable(Of AFAttribute) Dim instance As AFAttributeSearch Dim startIndex As Integer Dim pageSize As Integer Dim returnValue As IEnumerable(Of AFAttribute) returnValue = instance.FindAttributes(startIndex, pageSize)
public: [BrowsableAttribute(false)] [ObsoleteAttribute(L"This method has been replaced by FindObjects.")] IEnumerable<AFAttribute^>^ FindAttributes( int startIndex = 0, int pageSize = 0 )
[<BrowsableAttribute(false)>] [<ObsoleteAttribute("This method has been replaced by FindObjects.")>] member FindAttributes : ?startIndex : int * ?pageSize : int (* Defaults: let _startIndex = defaultArg startIndex 0 let _pageSize = defaultArg pageSize 0 *) -> IEnumerable<AFAttribute>
Parameters
- startIndex (Optional)
- Type: SystemInt32
The starting index (zero based) of the items to be returned. - 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: IEnumerableAFAttributeReturns an enumerable list of the AFAttribute objects found using the search tokens for this search object.
Exceptions
| Exception | Condition |
|---|---|
| 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 the level of all TankElements. 11int count; 12using (var search = new AFAttributeSearch(myDB, "FindTankLevel", @"Element:{ Name:'TankElement*' } Name:'Level'")) 13{ 14 search.CacheTimeout = TimeSpan.FromMinutes(10); 15 16 count = search.GetTotalCount(); 17 Console.WriteLine("Found {0} Attributes.", count); 18 foreach (AFAttribute item in search.FindObjects()) 19 { 20 Console.WriteLine(" Element {0} has {1} Attributes", item.Name, item.Attributes.Count); 21 } 22}
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 the level of all TankElements. 13Dim count As Integer 14Using search As New AFAttributeSearch(myDB, "FindTankLevel", "Element:{ Name:'TankElement*' } Name:'Level'") 15 16 search.CacheTimeout = TimeSpan.FromMinutes(10) 17 18 count = search.GetTotalCount() 19 Console.WriteLine("Found {0} Elements.", count) 20 For Each item As AFAttribute In search.FindObjects() 21 Console.WriteLine(" Element {0} has {1} Attributes", item.Name, item.Attributes.Count) 22 Next 23End 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: 2.10.0, 2.10, 2.9.5Obsolete (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