[英]In NHibernate how would I map an object to only retrieve it's children but ignore them when creating or updating?
在創建對象或將對象更新到數據庫時,如何映射該對象以僅檢索下面的集合並完全忽略它?
<bag name="children" table="tb_parent_child" lazy="false">
<key column="parentID"/>
<one-to-many class="Child"/>
</bag>
謝謝
為什么不將懶惰設置為true? 那基本上不是嗎? 也許還可以將層疊設置為“無”?
將級聯屬性設置為none:
<bag name="children" table="tb_parent_child" lazy="false" cascade="none">
<key column="parentID"/>
<one-to-many class="Child"/>
</bag>
應該做到這一點。 有關級聯選項的描述,請參見此博客條目 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.