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")
精彩评论