现有三个表定义如下:
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; }
}
我尝试了以下覆盖:
BusinessUnit
自动映射覆盖:
mapping.HasMany(x => x.Categories)
.Table("pp_paragraphs")
.KeyColumn("business_unit_fk")
.Inverse();
Category
自动映射覆盖:
mapping.HasMany(x => x.Categories)
.Inverse();
我有很多和多对一的约定来处理列名,所以我认为我不需要在这里指定(或者至少我不这么认为)。自动映射器负责处理Paragraph
.
has-many 映射BusinessUnit
不起作用。我怎样才能做到这一点?