Retrieving an Object
Here is standard .NET (C#) code that uses .NET proxy objects to display the data for a PERSON record. In detail, the code does the following:
-
Opens an instance of the .NET proxy class PERSON. This class is the proxy for the Caché MVFILE.PERSON class. Each proxy for a persistent Caché class has an Open method. This method opens an instance of the proxy in the .NET runtime as well as the corresponding Caché object in the Caché server. The method takes both the Caché object ID for the instance as well as an open CacheConnection object as arguments.
-
Retrieves the Caché object's property values using the corresponding properties of the proxy.
-
Retrieves each of the elements of the PHONE array. The .NET proxy represents this array as an instance of CacheListOfStrings.
MVFILE.PERSON person = MVFILE.PERSON.OpenId(cnCache, "1");
Console.WriteLine("Name: {0} Age: {1} Hair: {2}",
person.Name, person.Age, person.Hair);
CacheListOfStrings phones = person.Phone;
foreach (String pn in phones)
Console.WriteLine (pn);
The above code is contained in ObjectAccess.cs. This file is in <cachesys>\Dev\tutorials\mv. Executing the .NET Examples contains step-by-step instructions for executing this code.