This is a part of my entity-relationship model:
I found few ways to map the 'It' relationship:
One: Add new class, and then reference it using a many to many relatinship:
class It{
A a;
B b;
C c;
}
class A{
public virtual ISet<It> Relationship{set;get;}
}
However, I fear NHibernate might add an ID to 'It' on its own, or I that I might have to use a composite key (which isn't a good practice).
Two: I found this. Which uses two separate collections on each class to model a three way relationship. But I think there will be an unnecessary effort to access the information later, plus it's a bit trickier to get the mapping right.
Instead, I figured I could do something like:
class A{
IList<Tuple<C, D>> ARelationship;
}
That way you have the two references together from the beginning. But I haven't been able to find an example on how to do such mapping (a list of tuples). I found you could define an ICompositeUserType subclass to do that, however I don't fully understand how that works or how to use it to solve my problem.
My question(s) being: What's the best way to model such a relationship?
If it's by using a separate class (method one), what's the best way to map it from the viewpoint of each class, and how to map the newly defined class?
If it's by using a list of tuples, is it possible to map it without using ICompositeUserType? How?
Also, I might have missed the answer by doing incorrect Google searches. Are there other options?