views:

32

answers:

1

Hello all,

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?

A: 

Why not use inheritance?

Check out this question

http://stackoverflow.com/questions/655494/inheritance-mapping-with-fluent-nhibernate

And this page (search inheritance to jump to the right section)

http://wiki.fluentnhibernate.org/Fluent_mapping

Zoidberg
The schema was simplified to show the keys and such. In reality two objects have a different relationship, which should not be expressed as subclasses.
Vasili Sviridov