Object of %SerialObject class to List
Hi.
Is it possible to convert the object of type %SerialObject to $List form? I'm using embedded class in unique index and I want to use autogenerated method Open to access the object - parameter should be in $List form...
Tnx.
Regards,
Matjaž
Comments
don't think so complicated. leave your serial object as it is
but use instead a CALCULATED, SQLCOMPUTED Property as $LB() and you can then index it
Tnx for you answer, but I'm not sure I understand it. I don't have problem with index but with Open method:
Set attributes=##class(Packing.Needs.Attributes).%New() //%SerializeObject
Set attributes.Source="SYS"
Set need=##class(Packing.Needs.State).StateIdOpen(json."Department",technicalProduct.%Id(),$ZDate(+$Horolog,3)_" 00:00:00",json."DeliveryBy",attributes,4) //attributes parameter should be in $List format
Ok. the picture becomes clearer:
%SerialObject is stored as $LB($LB(....),...)
you can get your result by 2 steps.
do attribute.%SerializeObject(.serialraw)
set list=$list(serialraw)Hi.
It works although in the documentation stays:
method %SerializeObject(ByRef serial As %Binary, partial As %Integer = 0) as %Status [ Language = objectscript ]
This method retrieves all of the serial values for referenced objects and places them into the instance variables, Validates, Normalizes, and serializes the object (with a save of the persistent image if persistent).
This method is not meant to be called directly. It is called by %Save and by %GetSwizzleObject.
Tnx!
Regards,
Matjaž
Zdravo Matjaž!
you are right in principle. Though there are hundreds of similar cases since DECADES!
ok, the cleaner solution brings us back to my previous proposal.
add a calculated property to your serial class ##class(Packing.Needs.Attributes) like this
Property List As %List [ Calculated, SqlComputed,
SqlComputeCode = { set {*}= $LB({attr1},{attr2},{attr3},{attr4} ) }, SqlComputed ];
attr1,attr2,attr3,attr4 have to be the SQLnames of these properties !!!
WARNING#1: you have to maintain this list manually at every change of the attributes!
WARNING#2:: this calculation happens at every access to the object.
The additional parameter SqlComputeOnChange = (attr1,attr2,attr3,attr4)
may reduce this. though I've never tried in practice
Hi.
I'll stick with first one. Tnx again.
Regards,
Matjaž
P.S.
Where are you comming from (you know word like "Zdravo" :) )?
I come from Vienna, Austria.
I guess we are "neighbors" according to your mail (.si)
Pretty close, I'm from Ptuj, near Maribor...
dobrodošli
[Google translate is my helper]