流畅的NHibernate:与Product到Product的多对多关系。我可以在asp.net mvc上实现它
public class Product
{
public virtual int Id { get; set; }
public virtual IList<Product> ManyProduct { get; set; }
}
映射
public class ProductMap : ClassMap<Product>
{
public ProductMap()
{
Id(x => x.Id);
Map(x => x.ImageUrl);
}
HasManyToMany(x => x.ManyProduct)
.Cascade.All()
.Table("ProductInProduct");
}
答案 0 :(得分:0)
您没有明确说出错误,但您的HasManyToMany
定义需要指定ProductInProduct
表中的Parent和Child Id列:
HasManyToMany(x => x.ManyProduct)
.Table("ProductInProduct")
.ParentKeyColumn("ParentId")
.ChildKeyColumn("ChildId")
.Cascade.All();