Question
· 5 hr ago

Accessing %Collection.ListOfObj within .NET using the Native SDK

I am migrating from HealthShare 2015 to Health Connect 2025 as part of an infrastructure upgrade. We have several C# .NET Razor web apps that interact with HealthShare using the InterSystems.Data.CacheClient assembly, and the Cache Object Binding Wizard for .NET to build the C# proxy classes. This has worked flawlessly for about 6 years.

I am now switching to using the Native SDK with the InterSystems.Data.IRISClient assembly and using the C# IRISReference and IRISObject. I have been able to rewrite nearly all the code in our web apps to use the new mechanism, with the exception of lists of objects.

As an example, I have the following Caché classes:

Class TestClasses.Entries Extends %RegisteredObject
{
Property Entries As list Of TestClasses.Entry;
}

Class TestClasses.Entry Extends %RegisteredObject
{
Property Domain As %String;
Property Username As %String;
}

A classmethod has an output parameter of TestClasses.Entries, with a return type of %Status.

Class TestClass
{
ClassMethod Method1(output pReturn As TestClasses.Entries) As %Status
{
    Set pReturn = ##class(TestClasses.Entries).%New()
    Set tObject1 = ##class(TestClasses.Entry).%New()
    Set tObject1.Username = "user1"
    Do pReturn.Entries.Insert(tObject1)
    Set tObject2 = ##class(TestClasses.Entry).%New()
    Set tObject2.Username = "user2"
    Do pReturn.Entries.Insert(tObject2)
    Quit $$$OK
}
}

Within C# I can get the Entries object and can see the type and OREF of the Entries property.

IRISReference irisReference = new(0);
iris.ClassMethodStatusCode("TestClass", "Method1", irisReference);
IRISObject irisObject = (IRISObject)irisReference.value;
Console.WriteLine(irisObject.GetOREF())
// prints: 5@TestClasses.Entries

IRISObject irisObject2 = (IRISObject)irisObject.GetObject("Entries");
Console.WriteLine(irisObject2.GetType())
// prints: InterSystems.Data.IRISClient.ADO.IRISObject
Console.WriteLine(irisObject2.GetOREF())
// prints: 8@%Collection.ListOfObj

IRISList irisList = irisObject.GetIRISList("Entries");
Console.WriteLine(irisList.ToString());
// prints: $lb()
Console.WriteLine(irisList.GetType());
// prints: InterSystems.Data.IRISClient.ADO.IRISList

But I cannot find any way to interact with the list of Entry objects or their properties. I've tried pretty much every combination of the various IRIS C# methods that I can see and have looked through the SDK documentation. The example above is a simple version of what some of our clinical web apps do; other methods have multiple input and output parameters with large objects with nested lists of objects.

Is %Collection.ListOfObj not supported via the Native SDK, or am I just doing it wrong/missing something obvious?

Product version: IRIS 2025.1
$ZV: IRIS for Windows (x86-64) 2025.1 (Build 223U)
Discussion (2)1
Log in or sign up to continue
    var irisReference = new IRISReference("");
    iris.ClassMethodStatusCode("TestClasses.TestClass", "Method1", irisReference);
    var pReturn = (IRISObject)irisReference.value;
    var list = (IRISObject)pReturn.Get("Entries");
    for (var i = 1; i <= list.InvokeLong("Count"); i++)
    {
        var entry = (IRISObject)list.InvokeObject("GetAt", i);
        Console.WriteLine(entry.GetString("Username"));

    }