Creating Classes to Use in the Examples
To complete the following hands-on examples, use Microsoft Visual Studio Code (VS Code) to create the following classes: MyPackage.TestMe and 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 } }