This is my current code structure for the business layer -
Now, both my domain objects depend on
I have read articles where it says domain objects should not have any dependencies on repositories. So my question is in two parts -
Thanks!
In DDD, the domain layer will be inner most layer that encapsulates all the domain logic. It is recommended not to have any dependencies in your domain classes.
In your scenario, it is ideal to use Domain Events
Company domain should raise an event, e.g. "OnPolicyChanged", and this event should be listened at the UserManager and manager should invoke the domain logic in the User domain.
It is not ideal to include the persistence logic in your domain layer. It should be at a higher level, e.g. A service/Infrastructure layer which should commit the changes to the database.