I have a S table. It can have some Children. The Children are same type(S).
Table : S(Id,Name)
Table : S_R(Parent_S_Id,Child_S_Id)
Classes are
public class S
{
public virtual int Id { get; set; }
public virtual string Name { get; set; }
public virtual IList<S> Children { get; set; }
public S()
{
this.Children = new List<S>();
}
public virtual void AddChildren(S s)
{
this.Children.Add(s);
}
}
public class SMap : ClassMap<S>
{
public SMap()
{
Table("S");
Id(x => x.Id, "Id").GeneratedBy.Increment();
Map(x => x.Name, "Name");
HasManyToMany<S>(x => x.Children)
.Table("s_r")
.ParentKeyColumn("S_ID")
.ChildKeyColumn("CHILD_S_ID")
.Cascade.All()
.LazyLoad()
.Inverse();
}
}
but it doesn't work. It is not saving relation in relation table. Could anyone have any idea and view. Please share your view and suggestion.