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

AF SDK Reference

AFAnalysisService.QueryRuntimeInformation(TObject) Method (String, String, Func(IList(AFAnalysisService.RuntimeFieldValue), TObject))

AFAnalysisService.QueryRuntimeInformation(TObject) Method (String, String, Func(IList(AFAnalysisService.RuntimeFieldValue), TObject))

  • Last UpdatedNov 18, 2025
  • 4 minute read
AFAnalysisService.QueryRuntimeInformation(TObject) Method (String, String, Func(IList(AFAnalysisService.RuntimeFieldValue), TObject))
This method allows you to customize the output after querying fields of analyses from PI Analysis Service.

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

Syntax

public IEnumerable<TObject> QueryRuntimeInformation<TObject>(
	string queryString,
	string fields,
	Func<IList<AFAnalysisServiceRuntimeFieldValue>, TObject> factory
)
Public Function QueryRuntimeInformation(Of TObject) ( 
	queryString As String,
	fields As String,
	factory As Func(Of IList(Of AFAnalysisServiceRuntimeFieldValue), TObject)
) As IEnumerable(Of TObject)

Dim instance As AFAnalysisService
Dim queryString As String
Dim fields As String
Dim factory As Func(Of IList(Of AFAnalysisServiceRuntimeFieldValue), TObject)
Dim returnValue As IEnumerable(Of TObject)

returnValue = instance.QueryRuntimeInformation(queryString, 
	fields, factory)
public:
generic<typename TObject>
IEnumerable<TObject>^ QueryRuntimeInformation(
	String^ queryString, 
	String^ fields, 
	Func<IList<AFAnalysisServiceRuntimeFieldValue^>^, TObject>^ factory
)
member QueryRuntimeInformation : 
        queryString : string * 
        fields : string * 
        factory : Func<IList<AFAnalysisServiceRuntimeFieldValue>, 'TObject> -> IEnumerable<'TObject> 

Parameters

queryString
Type: SystemString
Query string to filter the results.
fields
Type: SystemString
Expected fields to be returned.
factory
Type: SystemFuncIListAFAnalysisServiceRuntimeFieldValue, TObject
Factory to convert the results into a desired object.

Type Parameters

TObject
The user-defined type of the object that the returned fields are mapped into using the specified factory delegate.

Return Value

Type: IEnumerableTObject
Value lists of AFAnalysisServiceRuntimeFieldValue objects corresponding to the specified fields.

Exceptions

ExceptionCondition
InvalidOperationExceptionThis exception is thrown when connection to the analysis service fails for any reason.
ArgumentNullExceptionThis exception is thrown when fields is or factory is .

Remarks

This method queries analyses runtime status from PI Analysis Service. The operation takes a query string and expected field names along with the results factory that is applied to ListT objects.

Security note Security Note
Only information about the analyses that you have Read security right is returned.

The argument queryString can be used to filter analyses by the supported fields from RuntimeInformationFields. The query language syntax is similar to that of AFSearch with the following notable differences:

  • All the search conditions are implicitly AND. The AND keyword itself is not supported in the syntax.
  • An empty string always matches an empty string, even for the Name filter.
  • IN operator is supported only for strings.
  • Contextually invalid comparisons such as "Name := 10" always default to FALSE, rather than throwing an exception.
  • Time-stamps must be specified as strings.
  • Ordering and limiting the number of responses are all part of the queryString syntax. The following fields can be used: sortyBy, sortOrder, and maxCount.

The argument fields is used to specify the requested fields as a space-separated list. At least one field must be specified. For supported field names, see RuntimeInformationFields.

Note Notes to Callers
When analysis has not evaluated, runtime fields such as lastLag, lastElapsed, etc. will return the default values.

Examples

Below are some example queries:

  • name := 'Analysis*'
  • path := '*Database1*Element1*Analysis*'
  • lastTriggerTime :< '*-1m'
  • status :in ('Running', 'Warning')
  • lastEvaluationStatusDetail := 'Error' lastLag :> 10000

// Retrieve query results that are converted to an anonymous type.
var resultsWithFactory = analysisService.QueryRuntimeInformation(
    "path: '*Database1*Steam*' status :in ('Running', 'Warning') sortBy: 'lastLag' sortOrder: 'Desc'", 
    "id name status lastLag lastTriggerTime",
    (list) => new
        {
            id = (Guid)list[0],
            name = list[1],
            status = list[2],
            lastLag = list[3].ToObject<double>(),
            lastTriggerTime = list[4].ToObject<AFTime>(AFTime.MinValue)
        }
    );

// The results can be very easyly converted to JSON with Newtonsoft JSON converter if the library is available
string json = Newtonsoft.Json.JsonConvert.SerializeObject(resultsWithFactory, Newtonsoft.Json.Formatting.None);

if (!resultsWithFactory.Any())
    return;

// Get values of the first result explicitly
var firstResult = resultsWithFactory.First();
Guid id = firstResult.id;
string name = firstResult.name;
string status = firstResult.status;
double lastLag = firstResult.lastLag;
AFTime lastTriggerTime = firstResult.lastTriggerTime;

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

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