VB.NET에서 InterSystems Cache '의 파생 클래스 (테이블)를 처리하는 방법
마지막으로 만든 TestClass를 기반으로합니다.
파생 클래스를 TestClassInhelit이라는 이름으로 만듭니다. Extends를 선택하고 User.Main.TestClass를 설정합니다.


파생 클래스를 다음과 같이 작성합니다.

★☆중요
Studio의 TestClass의 기본 클래스에 다음 코드를 추가합니다. 이것은, VB로 조작할 때, Cache'에 받아들인 클래스의 규정 동작이, (operator=)에 대해서 「데이터베이스 주소를 대입한다」라고 하는 움직임이 되어, 자주(잘) 사용되는(대입한다)의 움직임이 됩니다 아니. 이것을 실현하는 것이이 GetClone 함수입니다.
TestClass.cls
Method GetClone(deep As %String = 1) As User.Main.TestClass [ Language = cache ]
{
//OK
Quit ..%ConstructClone(deep)
}

VB.NET에 설정한 ObjectBinding의 기능으로 TestClass와 TestClassInhelit를 >로 꺼내 Generate 버튼으로 생성하고 VB.NET의 '추가 → 기존 항목'에서 ObjectBinding2.vb를 추가합니다.

VB.NET 측에서 Button3을 만들고 다음과 같이 작성합니다. GetClone을 사용하는 장소에 주목하십시오. 덧붙여 객체 지향 프로그래밍에 있어서의 파생 클래스의 캐스트와 같이, 기저 클래스에서 생성된 변수는 (파생 클래스형의 데이터)를 모두 가지게 됩니다.

Button3_Click()
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
'派生クラスを呼ぶ方法
Dim cacheConnectStr As String = "Server = localhost; Port=1972;" +
"Log File = C:\VSProject\NewCarte\NewCarte\NewCarte\bin\NewCarte.log; Namespace = USER;" +
"Password = yourpass; USER ID = yourid"
Dim cnCache As CacheConnection = New CacheConnection(cacheConnectStr)
cnCache.Open()
Dim d2 As User.Main.TestClassInhelit
d2 = New User.Main.TestClassInhelit(cnCache)
d2.name = "Nakagawa Saburou"
d2.age = 34
d2.name2 = "Sanchan"
d2.age2 = 35
d2.Save()
d2.Close()
'そもそも、Cache'クラスにおける(operator =)は、「同じデータベースの箇所」を参照することになるので、以下のように記述する
Dim d11 As New User.Main.TestClass(cnCache)
d11 = d2.GetClone("1") '★注意:d11=d2とすると、単にd2と同じレコードを参照してしまう!
'★注意:d22 = TryCast(d1, User.Main.TestClass) 、 d22 = d1.GetClone("1")はいずれもエラーになる!
'd11はTestClassInhelitのデータをすべて持つ
d11.Save()
d11.Close()
End Sub
실행 결과(ID=20이, 기본 클래스에서 인스턴스를 생성해, 파생 클래스의 캐스트를 해 보존한 결과. 기본, Cache'는 MUMPS의 유연성을 살려, 데이터가 사라지는 측에 데이터 조작을 하지 않는 경향에 있다.)


Reference
이 문제에 관하여(VB.NET에서 InterSystems Cache '의 파생 클래스 (테이블)를 처리하는 방법), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/torisan_/items/9d68d090c56ec4ddd8a5텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)