0
votes

I have a class A in which there is a string BName and the table in db corresponding to class A has column int BID.

There is also a class B in which int BID id primary key and has other fields like string BName.

Many rows in TableA can have same BID. Also BID can be null in TableA.

We are getting the data for class A using nhibernate. I need to have BName in the class corresponding to BID in the DB for the TableA. What property or mapping should I define in hbm.xml.

1

1 Answers

0
votes

I believe you are looking at a simple many to one relationship. You need a reference to B, MyB in your A class and you can then access MyB.BName.

public class A{

     public virtual B MyB{get;set;}

}

<many-to-one name="MyB" class="B" column="BID"/>