I have a child table containing the parent id. This is a one-to-one mapping, but values ββmay not be present in the child table. I have problems displaying this without getting errors, though ... I tried several things; display of the same column with different properties, etc.
Parent table
int id
Child table
int parentid
Parent class
int id
Child class
Parent parent // note I'm referencing parent, not using an int id ..
Mapping
Id(x => x.Parent) .Column("parentid"); // fails Id(x => x.Parent.Id) .Column("parentid"); // fails References(x => x.Parent) .Column("parentid"); // fails - missing id // Adding an id field in addition to parent for // child class (id is then the same as parent.id) // fails on save Id( x => x.Id ) .Column("parentid"); References(x => x.Parent) .Column("parentid");
I would like the child class to not have a separate Id field, but rather a reference to the parent, since there can never be a child without a parent. However, in the database, I just want to save the parent id.
Any ideas how I can do this?
fluent-nhibernate- nhibernate-mapping
simendsjo
source share