开发者

NHibernate child and parent have different key names?

开发者 https://www.devze.com 2023-04-05 17:44 出处:网络
I\'m working with an existing database and can\'t change the schema.Lets say we sell widgets.Each order for widgets has an entry in the WidgetBase table with a key name开发者_Go百科d uid. Now, the spe

I'm working with an existing database and can't change the schema. Lets say we sell widgets. Each order for widgets has an entry in the WidgetBase table with a key name开发者_Go百科d uid. Now, the specific parameters needed for each widget in the order are contained in another table called WidgetParams. WidgetParams has a column called TBuild that links to the uid column in the WidgetBase table.

How do I do the mapping in nHibernate when the key names are different?


You can specify the name of the foreign key column on both sides (if mapping bi-directional)

Widget

HasMany<WidgetParams>(x => x.widgetParams)
    .KeyColumn("TBuild")

WidgetParams

References<Widget>(x => x.widget)
    .Column("TBuild")
0

精彩评论

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