There is error in code IMHO.
== operator ill not work correctly as there is reference type and each property eg. AB - returns new object instance.
Either use record or override equals so it checks for the code or make AB property return that same object (in case there is no way to create new objects with custom values).
Customer support service by UserEcho