Skip to main content

Executing a Routine

You can also use .NET proxies to execute basic routines. For example, MyAccount contains the GETVALUE subroutine. The routine accepts a record ID, an attribute name, and a value number as arguments. It returns the corresponding piece of multivalue data. Here are the steps for executing this routine from .NET:

  1. Create a Caché class and add a method, like the following, that wraps a call to the routine. Note that the Caché class need not be persistent. It contains no data and its method is a class method. The class can extend %RegisteredObjectOpens in a new tab.

    
    ClassMethod GetValue(ID As %String, ATTRNAME As %String, VNO As %String) 
     As %String
    {
      CALL GETVALUE(ID,ATTRNAME,VNO,VALUE)
      RETURN VALUE
    }   
    
    
  2. Create a .NET proxy for the Caché class.

  3. Execute the routine from your .NET code using the proxy. Here is example .NET (C#) code:

    
    String Name = MVExample.Search.GetValue(cnCache, "1", "NAME", "1");
    Console.WriteLine("NAME: {0}", Name);    
    
    

    Note the following about these lines of .NET code:

    • Search is the .NET proxy for the Caché class containing GetValue.

    • The Caché GetValue method is a Class Method, which projects to a C# static method. No instance of Search is required to execute it.

    • The cnCache variable represents an open CacheDatabase object.

Note:

The above Caché GetValue method is in MVExample.Search, which is contained in MVExample.xml. The above .NET code is contained in ObjectAccess.cs. Both files are in <cachesys>\Dev\tutorials\mv. Importing a File Using Studio contains step-by-step instructions for importing and installing Caché code. Executing the .NET Examples contains step-by-step instructions for executing the .NET code.

FeedbackOpens in a new tab