0

现有三个表定义如下:

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不起作用。我怎样才能做到这一点?

4

1 回答 1

0

你必须在这里使用 HasManyToMany

于 2011-02-08T10:26:22.087 回答