问题
fluent NHibernate: many-to-many relationship with Product to Product.how i can implement it on asp.net mvc
public class Product
{
public virtual int Id { get; set; }
public virtual IList<Product> ManyProduct { get; set; }
}
Mapping
public class ProductMap : ClassMap<Product>
{
public ProductMap()
{
Id(x => x.Id);
Map(x => x.ImageUrl);
}
HasManyToMany(x => x.ManyProduct)
.Cascade.All()
.Table("ProductInProduct");
}
回答1:
You don't specifically say what is wrong but your HasManyToMany
definition needs to specify the Parent and Child Id columns from your ProductInProduct
table:
HasManyToMany(x => x.ManyProduct)
.Table("ProductInProduct")
.ParentKeyColumn("ParentId")
.ChildKeyColumn("ChildId")
.Cascade.All();
来源:https://stackoverflow.com/questions/16916185/fluent-nhibernate-many-to-many-relationship-with-product-to-product