2010-11-08 66 views
4

好日子所有如何刪除NHibernate的許多一對多的關聯,但不刪除引用的對象

我無法刪除兩個對象之間的關聯沒有NHibernate的刪除對象。我的映射文件:

<?xml version="1.0" encoding="utf-8" ?> 

<property name="Name" column="[SiteGroupName]"/> 

<many-to-one name="ClientInfo" column="[ClientID]"/> 

<set name="internalSites" table="SiteGroupSites" cascade="none" inverse="true"> 
    <key column="[SiteGroupID]"/> 
    <many-to-many class="Site" column="SiteID"/> 
</set> 

<set name="internalSiteGroups" table="SiteGroupGroups" cascade="none" inverse="true"> 
    <key column="[SiteGroupID]"/> 
    <many-to-many class="SiteGroup" column="ChildSiteGroupID"/> 
</set> 

所以在我的C#代碼,我從SiteGroup刪除網站:

siteGroup.Sites.Remove(site); 

我不明白的是,當我保存時,它會刪除關聯和實際網站。我誤解了什麼嗎?我想要的是將網站從SiteGroup中刪除,而不是完全刪除。

任何幫助將不勝感激。

+0

您是否設法解決您的問題Fouche? – HerbalMart 2012-11-05 08:35:13

回答