Question
· Dec 12, 2016

Iterating through all properties of an object

Is there a better way to iterate through all properties of an object than the following? Perhaps without needing to open a definition of the class but directly against the object?


SAMPLES>set t=##class(HoleFoods.Transaction).%OpenId(1)                          
SAMPLES>set def=##class(%Dictionary.ClassDefinition).%OpenId("HoleFoods.Transaction")
SAMPLES>for i=1:1:def.Properties.Count() {  w def.Properties.GetAt(i).Name_":"_$property(t,def.Properties.GetAt(i).Name),!  }
Actual:0
AmountOfSale:4.95
Channel:2
Comment:
DateOfSale:62373
Discount:0
Latitude:
Longitude:
Outlet:35@HoleFoods.Outlet
Product:37@HoleFoods.Product
TargetAmount:
UnitsSold:1
ZipCode:
Discussion (6)1
Log in or sign up to continue