What would the basic C# code look like to model a many-to-many relationship, where the relationship itself has attributes? And also in this case the many-to-many was referential. So a possible database model for this might look like the following (just to give an example of what I’m talking about)
- Nodes
- ID
- Name
- Description
- Relationships
- Parent_ID
- Child_ID
- Relationships_Type
The most important (and easily botched) component of this is the
Relationshipsproperty on theNodeclass. The way I defined is the easiest way, but a more reliable way would be to model it in more of a database fashion, where you have a central relationship repository and theNodeis connected.This would allow for you to create a single
RelationshipRepositoryinstance, add your relationships betweenNodes using theAddfunction, and it will take care of the rest. Subsequent calls toRelationships,Children, orParentson one of the affectedNodes will automatically examine therelationshipSourceto determine the children, parents, or all relationships.