Ok, here goes my best at explaining the situation. Let's assume we have the following:
Code:
public interface A
{
}
public class B : A
{
}
public class C : A
{
}
public class Container
{
public ISet<A> Members;
}
What would be the appropriate way to map the 'Container' class' Members set? The problem is that Members is *technically* homogenous, but in practice contains instances of B & C, which are different types (siblings in the inheritance tree from A)
I tried setting up a many-to-any that looked like this:
Code:
<set name="Members"
table="container_members"
cascade="all-delete-orphan">
<key column="parent_id"/>
<many-to-any id-type="guid" meta-type="string">
<column name="member_type"/>
<column name="member_id"/>
</many-to-any>
</set>
but all I get is an exception stating that 'collection was not an association' which wasn't very helpful? Is there a better way of mapping this? joined-subclass' don't seem appropriate, particularly if B & C end up implementing other interfaces (it seems NHibernate won't let you declare the joined-subclass multiple times)
Thanks!