NHibernate与包含多个多对一引用的孙子表有许多关系
现有三个表的定义如下:NHibernate与包含多个多对一引用的孙子表有许多关系,nhibernate,fluent-nhibernate,has-many,automapping,Nhibernate,Fluent Nhibernate,Has Many,Automapping,现有三个表的定义如下: create table business_units (id number(10,0) not null, ... , primary key (id)) create table categories (id number(10,0) not null, ... , primary key (id)) create table paragraphs ( id number(10,0) not null, business_unit_fk number(
create table business_units (id number(10,0) not null, ... , primary key (id))
create table categories (id number(10,0) not null, ... , primary key (id))
create table paragraphs (
id number(10,0) not null,
business_unit_fk number(10,0),
category_fk number(10,0),
...,
primary key (id)
)
实体的定义如下:
public class BusinessUnit : Entity {
public virtual IList<Category> Categories { get; protected set; }
}
public class Category : Entity {
public virtual IList<Paragraph> Paragraphs { get; protected set; }
}
public class Paragraph : Entity {
public virtual BusinessUnit Category { get; set; }
public virtual Category Category { get; set; }
}
类别
自动映射覆盖:
mapping.HasMany(x => x.Categories)
.Table("pp_paragraphs")
.KeyColumn("business_unit_fk")
.Inverse();
mapping.HasMany(x => x.Categories)
.Inverse();
我有很多很多对一的约定来处理列名,所以我不认为我需要在这里指定(或者至少我不这么认为)。自动映射器处理段落
的多对一引用
对于
业务单元
有许多映射不起作用。我怎样才能做到这一点?您必须在这里使用HasManyToMany