My domain model looks like this:
class Group
{
private List<Person> persons;
public void AddPerson(Person p) {
persons.Add(p);
DoSideEffect()
}
public List<Person> GetPersons() {...}
}
Now I need to persist it. By DDD I cannot add any persistence attributes to this class so xml serializers will not work. BinaryFormatter cannot be used since the format should be readable. I can manually call GetPersons() and persist them - but how am I going to load them back? If I call AddPerson() then there is a side effect. The side effect should only happen when a person is "really" added to the domain, not with persistrancy.