コンテンツタイプ
ビデオ
所要時間
6分
レベル
入門
.NET アプリケーションで Native SDK を使用し、InterSystems IRIS® data platform からデータに直接アクセスする方法を学びます。
このビデオを「完了」にマークしてください。
コンテンツタイプ
ビデオ
所要時間
6分
レベル
入門
.NET アプリケーションで Native SDK を使用し、InterSystems IRIS® data platform からデータに直接アクセスする方法を学びます。
このビデオを「完了」にマークしてください。
| 参照 | タイムスタンプ | コード |
|---|---|---|
| InterSystems IRIS に接続し、Native SDK を使用してグローバル、クラスメソッド、ルーチンにアクセスする .NET アプリケーション。 | 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 コード | 4:19 | 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 コード。 | 4:40 | 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コード | 5:07 | 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 |
.NET アプリケーションを InterSystems 製品に 接続する (学習パス、3時間)で、.NET アプリケーションを InterSystems® の製品とテクノロジーに接続しましょう。
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.