Object Relations RRS feed

  • Question

  • Say I have a 'ShiipingAddress' class and an instance of that class may be a class within an 'Invoice' instance, or a member of a collection of a 'Customer' instance or a member of a collection of a 'Delivery Route' instance, etc. Is it possible, from within an instance of the 'ShippingAddress' object to tell what class it may be contained within? 

    Sunday, August 7, 2011 6:50 PM


  • Not without designing the class accordingly. You can choose many options

    1. Define a parent id and parant type attribute. Accept these in the constructor to enforce a link. This is probably the most practical way to maintain link.

    2. Define a link to the parent entity. The type can be an object.

    • Proposed as answer by Ali Hamdar Sunday, August 7, 2011 7:50 PM
    • Marked as answer by cunelson3 Sunday, August 7, 2011 9:03 PM
    Sunday, August 7, 2011 7:26 PM