25.01.2015 Views

Using Caché Objects - InterSystems Documentation

Using Caché Objects - InterSystems Documentation

Using Caché Objects - InterSystems Documentation

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

where oref is the OREF of the specific object, PropertyName is the name of the property to<br />

associate the data with, and RefId is the ID of the referenced object. For every reference<br />

property there are SetObject (using OID value) and SetObjectId (using ID value) methods.<br />

For example, to assign a particular saved Person object as the owner in a Car object, use the<br />

following code:<br />

Do car.OwnerSetObjectId(PersonId)<br />

where car is the OREF of the Car object and PersonId is the ID of the saved Person object.<br />

10.4.1.2 Modifying Referenced <strong>Objects</strong> <strong>Using</strong> Cascading Dot Syntax<br />

Once an object is associated with the reference, the properties within that object can be populated<br />

or modified using cascading dot syntax as follows:<br />

Set oref.PropertyName.RefPropertyName = value<br />

where oref is the OREF of the specific object to associate the data with, PropertyName is the<br />

name of the reference property, RefPropertyName is the name of a data type property within<br />

the referenced object to associate the data with, and value is the actual data. For example, to<br />

set the value of the Name property of a Car object' s Owner property, use the following code:<br />

Set car.Owner.Name = "Doe,Jane"<br />

where car is the OREF of the Car object and “Doe,Jane” is the desired name.<br />

If any of the values referred to within a cascading dot syntax expression is null (""), then the<br />

entire expression evaluates to null. For example:<br />

Set car.Owner = ""<br />

Write car.Owner.Name // prints ""<br />

Modifying <strong>Objects</strong><br />

10.4.2 Modifying Embedded Object Properties<br />

The data stored in an embedded object property exists as part of a separate object in memory<br />

but can only be stored as data embedded within a separate, persistent object. There are two<br />

ways to modifying an embedded object property:<br />

• Instantiate a new instance of the embedded object and associate that instance with the<br />

embedded object property.<br />

• Directly create and populate the embedded object property using cascading dot syntax.<br />

<strong>Using</strong> <strong>Caché</strong> <strong>Objects</strong> 73

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!