Fluent NHibernate Self Referencing Many To Many

后端 未结 2 902

I have an entity called Books that can have a list of more books called RelatedBooks.

The abbreviated Book entity looks something likes this:

public clas         


        
相关标签:
2条回答
  • 2021-02-08 16:35

    Rather than setting the cascade attribute, I think you need to simply empty the RelatedBooks collection before deleting a book.

    book.RelatedBooks.Clear();
    session.Delete(book);
    

    Cascading deletes is not typically done in a many-to-many relationship because it will delete the object at the other end of the relationship, in this case a Book.

    0 讨论(0)
  • 2021-02-08 16:35

    This just got updated:

    http://fluentnhibernate.lighthouseapp.com/projects/33236/tickets/115-self-referencing-relationships

    0 讨论(0)
提交回复
热议问题