Object Equality
Posted: Sat Mar 02, 2019 2:36 am
If I define an object as such
How do you handle object equality?
Basically I want to store an instance of this object and then later compare that instance with another instance and see if they are the same.
such as
In .NET, I could override Equals and GetHashCode or implement a Comparer. Is there something similar in LANSA or am I stuck doing property comparison?
Such as
Code: Select all
function options(*DIRECT)
begin_com role(*EXTENDS #PRIM_OBJT *LISTFIELDS #ListFields)
group_by name(#ListFields) fields(#HVBTC #HVPLCN #HVPLD #wk_Bool1)
define_pty name(TypeCode) get(*AUTO #HVBTC) set(*AUTO #HVBTC)
define_pty name(ControlNumber) get(*AUTO #HVPLCN) set(*AUTO #HVPLCN)
define_pty name(Description) get(*AUTO #HVPLD) set(*AUTO #HVPLD)
define_pty name(HasOptedIn) get(*AUTO #wk_Bool1) set(*AUTO #wk_Bool1)
end_com
Basically I want to store an instance of this object and then later compare that instance with another instance and see if they are the same.
such as
Code: Select all
if (#MyFirstObject = #MySecondObject)
* the two are the same
endif
Such as
Code: Select all
if (#CurrentPlan *IsNot *NULL)
if ((#CurrentPlan.TypeCode = #lItem.TypeCode) *AndIf (#CurrentPlan.ControlNumber = #lItem.ControlNumber))
* they are the same
endif
endif