If I wanted to do a has and belongs to many by the following object model:
Object 1 ----------->> O1_O2_link <<------------------ Object 2
fields for link:
o1: Object 1
o2: Object 2
where Object 1 and Object 2 have many O1_O2_link, is there any recommendations on:
- Fetching Object2’s as children of Object1, visa versa?
- add/remove Object2 to Object1, which would add the link as well? So create Object2 and then the link?
Is this all manually coded? Or is there some slicker way?
@dskjflksjadlkfj Do you still have issues or have you managed to solve this in the meantime?
Still have the issue - but I believe I wrote the issue incorrectly. Unable to close, please close and I’ll re-open.
If you have an instance of Object1, it will have an Object2Link property, which is a list of link objects. So you can use that list to get at its Object2’s.
Or you can fetch just the link objects, with a predicate for Object1. You can then use each link object to get the properties of Object1, Object2, and the extraProp of the link.
Yes, create a new link, set the Object1, Object2, and extraProp properties, and save it.
To remove, find the link that matches what you want to remove, and delete the link.
This topic was automatically closed after 166 days. New replies are no longer allowed.