例に使用するクラスの作成
以降で紹介する例を使用して学習するには、Microsoft Visual Studio Code (VS Code) を使用して、クラス MyPackage.TestMe と MyPackage.Contact を作成します。
MyPackage.TestMe
Class MyPackage.TestMe Extends %RegisteredObject
{
ClassMethod Add(arg1 As %Integer, arg2 As %Integer) As %Integer
{
Return arg1 + arg2
}
ClassMethod CreateContact(name As %String, type As %String) As MyPackage.Contact
{
Set contact = ##class(MyPackage.Contact).%New()
Set contact.Name=name
Set contact.ContactType=type
Return contact
}
ClassMethod GetContactsByType(type As %String) As %ListOfObjects
{
Set list=##class(%Library.ResultSet).%New()
}
}
MyPackage.Contact
Class MyPackage.Contact Extends (%Persistent, %Populate, %XML.Adaptor)
{
/// Describes the nature of the contact: Personal or Business
Property ContactType As %String(TRUNCATE = 1, VALUELIST = ",Business,Personal");
/// Represents a contact's name
Property Name As %String(POPSPEC = "Name()", TRUNCATE = 1) [ Required ];
Query ByContactType(type As %String) As %SQLQuery(CONTAINID = 1)
{
SELECT %ID FROM Contact
WHERE (ContactType = :type)
ORDER BY Name
}
}