Read multiple properties - Metasys - LIT-12013522 - Software Application - Basic Services client library for .NET (and COM) - Metasys API - 4.2

Metasys REST Client for .NET and COM Developer Guide

Brand
Metasys
Product name
Basic Services client library for .NET (and COM)
Metasys API
Document type
API Reference Guide
Document number
LIT-12013522
Version
4.2
Revision date
2021-04-07
Language
English (United States)

Use the following method to get multiple properties from multiple objects. This is useful if all the objects have the same type, or have the same target properties.

Table 1. Read multiple properties from multiple objects .NET signature
Library method name ReadPropertyMultiple
Description Get multiple properties from multiple objects.
Method signature IEnumerable<VariantMultiple> ReadPropertyMultiple(IEnumerable<Guid> ids,IEnumerable<string> attributeNames);
Method input parameters
  • ids: list of GUIDs of the objects that the method reads.
  • attributeNames: list containing the names of attributes that belong to the objects specified by the previous parameter ids, from which the method returns the values.
Return value A collection of VariantMultiple objects.
The following .NET C# code is an example of a successful multiple property read:
List<Guid> ids = new List<Guid> { id1, id2 };
List<string> attributes = new List<string> { "name", "description" };
IEnumerable<VariantMultiple> results = client.ReadPropertyMultiple(ids, attributes);

// Get the values for first object
var object1Values = results.ElementAt(0)

// Get name from first object
var name = object1Values.ElementAt(0).StringValue;

// Get description from second object
var description = object1Values.ElementAt(1).StringValue;

Console.WriteLine(name);
Console.WriteLine(description);
/*
Outputs:
ZN-T
Zone Temperature
*/