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

AF SDK Reference

IAFSearch(T).IsMatch Method

  • Last UpdatedNov 18, 2025
  • 4 minute read
IAFSearch(T).IsMatch Method
Determines if the specified object matches the search query.

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

Syntax

bool IsMatch(
	T item
)
Function IsMatch ( 
	item As T
) As Boolean

Dim instance As IAFSearch
Dim item As T
Dim returnValue As Boolean

returnValue = instance.IsMatch(item)
bool IsMatch(
	T item
)
abstract IsMatch : 
        item : 'T -> bool 

Parameters

item
Type: T
The object to check against the search query.

Return Value

Type: Boolean
Returns 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.

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 evaluate the search query and determine if the specified object 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.

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, 2.10.0, 2.10, 2.9.5, 2.9

See Also

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