开发者

How to delete Nhibernate many-to-many association without deleting referenced objects

Good day all

I am having trouble deleting the associations between two objects without deleting the objects in NHibernate. My mapping file:

<?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>

So in my C# code I Remove a Site from SiteGroup:

siteGroup.Sites.Remove(site);

What I don't understand is that when I save, it deletes the association and the actual site. Am I misunderstanding something? What I want is for Site to be Removed from SiteGroup, not completely deleted.

Any help will be highl开发者_运维百科y appreciated.


How about

site.Sitegroup = null; //Save

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜