Hi,
I want map my object model to NHibernate. There is one tricky part in my concept and I don't know if it is possible to do this in NHibernate.
I want to have a collection of trees. I have two classes (below, only important properties indicated). Component is a node of a tree and ComponentGroup is a collection of trees.
public class Component
{
public Component Parent { get; set; }
public IList<Component> SubComponents { get; set; }
public ComponentGroup Group { get; set; }
}
public class ComponentGroup
{
public IList<Component> Components { get; set; }
}
Now I want each Component to know which ComponentGroup it belongs to, so I need reference from every Component to ComponentGroup (Group property). But ComponentGroup should have only collection of root nodes (direct children) - Components collection. So this is something like one-to-half mapping ;) "one" side has reference only to some items from "many" side.
Do you have any ideas how to map something like this using NHibernate?