Say we have an Aggregate with Customer as the root and Address as an internal Entity (Addresses need to be distinguishable within the Customer Aggregate).
A common way of updating a particular Address for a Customer is
Customer customer = customerRepository.Find(id); customer.UpdateAddress(addressId, addressData);
I can’t help but think this is a waste. Instead of getting the customer from the persistent storage and using it to update the address I want to update the address directly.
If I can grab hold of my UoW (NHibernate’s Session) I could just call session.Update(addressData) and that would be that (provided addressData has the id in it).
But NHibernate is hidden behind the repositories and I only have a repository for customer since it is the aggregate root. I would have to have the following in my CustomerRepository.
Internally this would call SaveOrUpdate on the Session.
The quetion is how many DDD rules am I breaking with this?