NHibernate - how to configure associations not to use primary key
I'm working with a legacy database put together by some very strange people. I'm writing an NHibernate DAL over the top of it but running into some odd mapping scenarios.
In one example, I have a table with a number of fields includi开发者_运维技巧ng LE_RECNUM
(integer primary key) and LE_CODE
(string).
However, all relationships throughout the database join onto LE_CODE
, not LE_RECNUM
, for some unfathomable reason.
I need to specify that LE_RECNUM
is the Id in my mapping file, because I need the primary key to be generated when I insert records. However, I want all associations to use LE_CODE
instead of LE_RECNUM
.
Can anyone suggest how I might do this?
References(x => x.SomeProperty).Column("LE_CODE").PropertyRef(x => x.SomePropertyInParent);
精彩评论