简体   繁体   中英

nHibernate many-to-many mapping delete association only

I've seen this question asked here but I haven't found one that is answered correctly. I have a many-to-many mapping with these tables:

Collection
Items
Collection_Items

A Collection has many Items and an item can belong to many Collections . Collection_Items is the joining table.

If (using nHibernate ) I want to delete an Item or Collection and have it delete it's joining associations without also deleting it's children... how do I do that?

If you have an example it doesn't matter if it's XML or Fluent or attributes or whatever.

Also, I have foreign key constraints connecting the two tables to the joining table.

Any examples out there?

Thanks!

It turns out I just needed CascaseStyle.None on both side and to remove the Inverse = True from the Items side. Turns out this is a very simple mapping.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM