问题
I have two tables
tblPart
(
partId,
subpartId UNIQUE NULL
)
tblSubpart
(
subpartId
)
So I can only have zero or one subPart associated with the part at the same time.
I'm trying to map this as
ClassMap<Part>
{
HasOne(x=>x.Subpart);
}
and the convention rewrites the foreign key so it uses subpartId instead of partId.
however generated query ads
subpart.partId
into the query, which does not exist.
What am I doing wrong here?
回答1:
Why not use inheritance?
Check out this question
Inheritance Mapping with Fluent NHibernate
And this page (search inheritance to jump to the right section)
http://wiki.fluentnhibernate.org/Fluent_mapping
来源:https://stackoverflow.com/questions/3571368/fluent-nhibernate-one-to-one-mapping-with-synthetic-keys