Domain Model I am working on has root aggregate and child entities. Something like the following code:
class Order
{
IList Lines {get;se
I expose collections as ReadOnlyCollection and use AddX and RemoveX methods for maintaining the collections. We just switched to 3.5 and I'm thinking about exposing IEnumerable instead. In most cases with NHibernate the child has a reference to the parent so exposing Add and Remove methods allows you to maintain that relationship:
public void AddPlayer(Player player)
{
player.Company = this;
this._Players.Add(player);
}
public void RemovePlayer(Player player)
{
player.Company = null;
this._Players.Remove(player);
}