RelationshipDefinitions vs. defining relationships with Entities

We are building a custom connector for a project I am working on. Thus far, it was been pretty easy to expose entities using the IObjectDefinition / IPropertyDefinition interfaces.


We currently have a "Person" and a "CaseFile" entity defined. We are no wanting to expose the ability for someone to create a relationship between these two entities.


So far, we are having a tough time trying to find a good canonical example on how one might build an IRelationshipDefinition (we think that's what we're supposed to do?) in order to expose the fact that a Person can be related to a CaseFile (many to many).


Another caveat to this relationship is that we will possibly have properties about this relationship, such as "how" someone might be related to a CaseFile. We would also need to support the ability to detect when someone is added / removed from an individual CaseFile and respond accordingly.


My main questions are this:


  1. Is there a good example on how to expose the ability for a consumer of my IConnector to be able to add / remove children from a relationship?
  2. Are the RelationshipDefinitions the right construct for what I'm trying to do or should we create a PersonToCaseFileRelationship entity that exposes our ability to relate the two entities?


In a way, #2 feels like a more composable approach given that a source system may not always have a join table, etc. in a traditional RDBMS fashion to get at the information.


Any help / assistance would be greatly appreciated.

(1) Answer