AFSearch(T).IsMatch Method
- Last UpdatedNov 18, 2025
- 4 minute read
- PI System
- AF SDK 2024 R2
- Developer
Determines if the specified item matches the search query.
Namespace: OSIsoft.AF.Search
Assembly: OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182
Syntax
public bool IsMatch( T item )
Public Function IsMatch ( item As T ) As Boolean Dim instance As AFSearch Dim item As T Dim returnValue As Boolean returnValue = instance.IsMatch(item)
public: virtual bool IsMatch( T item ) sealed
abstract IsMatch : item : 'T -> bool override IsMatch : item : 'T -> bool
Parameters
- item
- Type: T
The item to check against the search query.
Return Value
Type: BooleanReturns if the specified item matches the search query. Otherwise is returned. If ThrowOnError is and an error is found in the query, then this method will return because the object does not match the query.
Implements
IAFSearchTIsMatch(T)
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 evaluate the search query and determine if the specified
item matches the query filters for the search.
The ThrowOnError property determines whether an
exception is thrown if an error is found in the query.
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 10DateTime startTime = DateTime.Now; 11 12//Create a search to find all elements starting with "MyEvent" in their name 13//and an end date less than or equal to the current time plus 1 hour. 14AFEventFrameSearch search = new AFEventFrameSearch(myDB, "FindEventFrame", @"MyEvent* End:<=*+1h"); 15AFEventFrame myEventFrame = new AFEventFrame(myDB, "MyEventFrame"); 16myEventFrame.SetStartTime(startTime); 17myEventFrame.SetEndTime(startTime.AddHours(1)); 18 19//IsMatch will evaluate to true if the new Element would match the 20//query supplied in AFSearch above. This avoids the need for having the SDK 21//do an actual RPC to the server as the match is evaluated on the client. 22bool match = search.IsMatch(myEventFrame); 23 24if (match) 25 Console.WriteLine("Event Frame {0} matched the supplied search query in the {1} search.", myEventFrame.Name, search.SearchName); 26else 27 Console.WriteLine("Event Frame {0} did not match the supplied search query in the {1} search.", myEventFrame.Name, search.SearchName);
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 12Dim startTime As DateTime = DateTime.Now 13 14'Create a search to find all elements starting with "MyEvent" in their name 15'and an end date less than or equal to the current time plus 1 hour. 16Dim search As New AFEventFrameSearch(myDB, "FindEventFrame", "MyEvent* End:<=*+1h") 17Dim myEventFrame As New AFEventFrame(myDB, "MyEventFrame") 18myEventFrame.SetStartTime(startTime) 19myEventFrame.SetEndTime(startTime.AddHours(1)) 20 21'IsMatch will evaluate to true if the new Element would match the 22'query supplied in AFSearch above. This avoids the need for having the SDK 23'do an actual RPC to the server as the match is evaluated on the client. 24Dim match As Boolean = search.IsMatch(myEventFrame) 25 26If match Then 27 Console.WriteLine("Event Frame {0} matched the supplied search query in the {1} search.", myEventFrame.Name, search.SearchName) 28Else 29 Console.WriteLine("Event Frame {0} did not match the supplied search query in the {1} search.", myEventFrame.Name, search.SearchName) 30End If
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.