I am new to the .NET MVC. However this "problem" I am stuck at looks pretty common, I cannot find any tutorial or stackoverflow thread that explains how to do it properly.
I have a class, MyClass which has two attributes of same type
public class MyClass : IEquatable<MyClass>
{
public virtual MyClass LeftChild { get; set; }
public virtual MyClass RightChild { get; set; }
...
}
Now I have problem with nhibernate mapping. At first I tried one-to-one mapping. I created new instance and DO NOT set Childs , persisted it (lets say Id=1), and pass this instance to View and I expected that RightChild will be NULL and LeftChild will be NULL. But in the debbug mode i can see, that the RightChild was set to MyClass with Id=1 (Like MyClass instance set itself to this attribute) and same with LeftChild.
Mapping MyClass.hbm.xml
...
<one-to-one name="LeftChild" class="MyClass"/>
<one-to-one name="RightChild" class="MyClass"/>
...
Is it right approach to do it with one-to-one or I should use something else ?