nhibernate : One to One mapping
Posted
by frosty
on Stack Overflow
See other posts from Stack Overflow
or by frosty
Published on 2010-05-15T13:26:06Z
Indexed on
2010/05/15
13:34 UTC
Read the original article
Hit count: 362
nhibernate
|nhibernate-mapping
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.
© Stack Overflow or respective owner