开发者

Fluent Nhibernate - Joining/reference table from two classes

开发者 https://www.devze.com 2023-04-08 21:06 出处:网络
I have three classes: Class A { string name IList<AB> list } Class B { name } Class AB { A a B b } Class B exists separate from A.It exists in its own right, and of is part of similar list

I have three classes:

Class A 
{
string name
IList<AB> list
}

Class B
{
name
}

Class AB
{
A a
B b
}

Class B exists separate from A. It exists in its own right, and of is part of similar lists in other classes This is why I have the reference table.

Problem is, automapper generate schema gives me this schema:

A{id, name}

B{id, name}

AB{id, AFK}

WIth regards to the AB schema, I'm expecting BFK in there as well, and I'm not expecting the id field, as it's not needed. It should be a composite PK between AFK and BFK.

I'm using automapper, with no overrides at the mo.

开发者_运维技巧

Please note, I do not want to include IList into my Class B, as it has no place there.

Please help - I have been looking all over for the solution to this, and I feel it should be a simple solution. Back when I modelled from ER direct to sql tables this was how I was told to do it if the entities were both strong.


unfortunately you have to override

HasMany(x => x.List)
    .Component(c =>
    {
        c.ParentReference(x => x.A);
        c.References(x => x.B);
    });
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号