New to FluentNHibernate =D
I have a parent/children classes as follows:
public class Parent
{
public virtual int ID { get; private set; }
public virtual string Name { get; set; }
public virtual IList<Child> Children { get; set; }
}
public class Child
{
public virtual int ID { get; private set; }
public virtual string Name { get; set; }
public virtual Parent ActiveParent { get; set; }
}
With mappings of:
public ParentMap()
{
Id(x => x.ID);
Map(x => x.Name);
HasMany(x => x.Children)
.Inverse();
.Cascade.All();
}
public ChildMap()
{
Id(x => x.ID);
Map(x => x.Name);
//Map(x => x.ActiveParent)
// .Column(ParentID);
}
The commented out area of the child map is the question I'm currently having trouble with. I'd like to be able to create a child object and call its' parent(ie, someChild.ActiveParent), but am unsure on how to map this via the fluent interface.
The table structure for the child table holds a parentid, with the intent of lazy loading the parent object if called. Any help is always greatly appreciated.