I understand that this post is old, but it still remains unanswered, so here it is:
The key here is that your model is wrong, imo.
The group must be a domain object with a simple read-only collection (members?). The responsibility for retrieving and saving the group belongs to the GroupRepository, which downloads data from the persistence store and restores the object.
For instance:
public class Group { private Collection<Person> _persons; public Group(Collection<Person> persons) { if (persons == null) throw new ArgumentNullException("persons"); _persons = persons; } public IEnumerable<Person> Persons { get { return _persons; } } public void AddPerson(Person p) { if (p == null) throw new ArgumentNullException("p"); _persons.Add(p); DoSideAffect(); } } public class GroupRepository { public Group FindBy(Criteria c) {
Use the dependency injection infrastructure (Spring.NET, MEF, Unity, etc.) and create the IGroupRepository interface, which can be entered into the application code to retrieve and save group domain objects.
source share