Hello Henrik, thank you for quick reply.
I really hadn’t initialized the collection in the class declaration as you suggest in your reply. I didn’t think it necessary, because I usually don’t do it for 1 to many relations and the ORM works fine. Still, I tried it and the behavior was the same.
I then started to test further and deeper and came to an odd conclusion:
- As this was a simple testing sample, I didn’t follow all coding best practices, I did not encapsulate the class variables, making them public instead. As a result I got the following:
- If the relation collection was not managed, even if the relation was built by adding new objects on both class A and Class B IList<> variables, no records were created in the relation table and obviously, no records were read when loading objects of type A or B from DB
If the relation collection was managed, the relation records are created in the relation table, but not loaded when loading objects of types A or B, i.e., when loading an object of type A, its IList<B> variable would not be filled, keeping the value null
- When I redid my project and encapsulated all variables of classes A and B, using FieldAlias to associate the properties with the private variables everything worked as I originally intended.
This result leads me to believe that unless there was something wrong with my tests, there may be some undocumented feature (AKA bug) in OpenAccess ORM when manipulating many-to-many relations between classes that do not contain encapsulated variables, i.e., classes in which all variables are public as opposed to classes in which all variables area private and made available through public properties.