Content Type
Video
Duration
6m
Level
Introductory
Learn how to use the Native SDK with your .NET application to access data directly from InterSystems IRIS®data platform.
Mark me "complete" for this video.
Content Type
Video
Duration
6m
Level
Introductory
Learn how to use the Native SDK with your .NET application to access data directly from InterSystems IRIS®data platform.
Mark me "complete" for this video.
| Reference | Timestamp | Code |
|---|---|---|
| A .NET application that connects to InterSystems IRIS and uses the Native SDK to access globals, class methods, and routines. | n/a | Begin code:using System;
using InterSystems.Data.IRISClient;
using InterSystems.Data.IRISClient.ADO;
namespace NativeApp
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
String port = "51774";
String host = "localhost";
String Namespace = "USER";
String username = "SuperUser";
String password = "SYS";
try
{
IRISConnection connection = new IRISConnection();
connection.ConnectionString = "Server = " + host + "; Port = " + port + "; Namespace = " + Namespace + "; Password = " + password + "; User ID = " + username;
connection.Open();
Console.WriteLine("Connected to InterSystems IRIS.");
// Create irisNative object
IRIS irisNative = IRIS.CreateIRIS(connection);
// Setting and getting a global
irisNative.set(967.47, "^stocks", "AMZN");
irisNative.set(50.29, "^stocks", "MSFT");
irisNative.set(159.83, "^ stocks", "TSLA");
Double amznPrice = (double)irisNative.GetDouble ("^stocks", "AMZN");
Console.WriteLine("The current price of AMZN is $" + amznPrice);
// Iterating over a global
IRISIterator iter = irisNative.GetIRISIterator("^stocks", null);
Console.WriteLine("walk forwards");
foreach (var v in iter)
{
String subscript = (string)iter.CurrentSubscript;
Console.WriteLine("The current price of " + subscript + " is $" + iter.Current);
}
// Calling a class method
String newStockName = irisNative.ClassMethodString("%Library.PopulateUtils", "StringMin", 3, 4).ToUpper();
Double newStockPrice = (double)irisNative.ClassMethodDouble("%Library.PopulateUtils", "Float", 0, 1000, 2);
irisNative.Set(newStockPrice, "^stocks", newStockName);
Console.WriteLine("Created new stock " + newStockName + " at current value $" + newStockPrice);
// Calling a routine
String irisVersion = (string)irisNative.FunctionString("PrintVersion", "^StocksUtil");
Console.WriteLine("The current version of InterSystems IRIS is " + irisVerion);
// Close connection and native object
irisNative.Close();
connection.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}End code |
| ObjectScript equivalent for getting and setting a global | 4:20 | Begin code:set ^stocks("AMZN") = 1582.32
set ^stocks("MSFT") = 94.18
set ^stocks("TSLA") = 325.61
set amznPrice = $get(^stocks("AMZN"))End code |
| ObjectScript code for iterating through global. | Begin code:set subscript = ""
for {
set sub = $ORDER(^stocks(sub), 1, val)
quit:(sub = "")
write !, "The current price of ", sub, " is $", val
}End code |
|
| ObjectScript equivalent for calling a class method | 5:08 | Begin code:set newStockName = $ZCONVERT(##class(%PopulateUtils).StringMin(3,4), "U") set newStockPrice = ##class(%PopulateUtils).Float(0,1000,2) set ^stocks(newStockName) = newStockPrice write "Created new stock " _ newStockName _ " at current value $" _ newStockPriceEnd code |
Connect your .NET applications to InterSystems® products and technologies with Connecting .NET Applications to InterSystems Products (learning path, 3h).
Also available in
![]()
Having an issue with the learning site? Want to provide feedback on a course? Contact us by emailing online.training@intersystems.com.
Please include all relevant information, including the page or course you are having trouble with, and any necessary screenshots.