Updating the collections of entities with NHibernate the correct way

Posted by karel_evzen on Stack Overflow See other posts from Stack Overflow or by karel_evzen
Published on 2010-01-08T18:18:28Z Indexed on 2010/06/02 8:03 UTC
Read the original article Hit count: 155

A simple question regarding how NHibernate works:
I have a parent entity that has a collection of other child entities. Those child entities have a reference to the parent entity they belong to. Now I want to implement an Add method to the parent entity that would add a child to it. Should that Add method only add the child to its new parents collection, or should it also update the parent reference of the child or should it also remove the added entity from its previous parents collection? Do I have to do all these things in that method or will NHibernate do something for me?

Thanks.

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET