nhibernate : One to One mapping
- by frosty
I have the following map. I wish to map BasketItem to the class "Product". So basically when i iterate thru the basket i can get the product name
<class name="BasketItem" table="User_Current_Basket">
<id name="Id" type="Int32" column="Id" unsaved-value="0">
<generator class="identity"/>
</id>
<property name="ProductId" column="Item_ID" type="Int32"/>
<one-to-one name="Product"
class="Product"></one-to-one>
</class>
How do specifiy that product should match BasketItem.ProductId with Product.Id
Also i've read that i should avoid one-to-one and just use one-to-many? If i was to do that how do i ensure i just get one product and not a collection.