c# - nhibernate : One to One mapping -


I have the following map: I want to map the tokytim in the "product" category, basically when I am through the basket I repeat it, I can get the name of the product

  & lt; Class name = "basketItem" table = "user_current_Basket" & gt; & Lt; Id name = "id" type = "int32" column = "id" not saved-value = "0" & ​​gt; & Lt; Generator class = "identity" /> & Lt; / Id & gt; & Lt; Property Name = "Product ID" column = "item_id" type = "int 32" /> & Lt; One-to-one name = "product" class = "product" & gt; & Lt; / One-to-One & gt; & Lt; / Square & gt;  

How does it specialize that the product should be linked to the basket item. Product Id with product

I have also read that one should avoid one and one should use only one - many? If I had to do this then how do I ensure that I get only one product and not a collection?

SELECT * BASKET ITEM WITH PRODUCTS IN BASKETITIM INER. ITM_ID = Products. ITM_ID

How does it make specific that the product should be produced from the basketsite . Product Id with product

Your basketIT should be product at the object level, not ProductId . And mapping should be:

  & lt; Class name = "BasketItem" table = "User_Current_Basket" & gt; & Lt; Id name = "id" type = "int32" column = "id" not saved-value = "0" & ​​gt; & Lt; Generator class = "identity" /> & Lt; / Id & gt; & Lt; One-to-one name = "product" class = "product" /> & Lt; / Square & gt;  

I have also read that one should avoid one and use only one-to-many? If I had to do this then how do I ensure that I get only one product and not a collection?

>

code> & lt; Class name = "BasketItem" table = "User_Current_Basket" & gt; & Lt; Id name = "id" type = "int32" column = "id" not saved-value = "0" & ​​gt; & Lt; Generator class = "identity" /> & Lt; / Id & gt; & Lt; Many-to-one names = "product" class = "product" /> & Lt; / Square & gt;

Comments