Fluent NHibernate one-to-one mapping with synthetic keys

一个人想着一个人 提交于 2019-12-12 01:35:48

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!