title: Repository Pattern: how to Lazy Load? or, Should I split this Aggregate?
body: <p>I have a domain model that has the concept of an Editor and a Project.</p>
  
  <p>An Editor owns a number of Projects, and a Project has not only an Editor owner, but also a number of Editor members.  Therefore, an Editor also has a number of "joined" Projects.</p>
  
  <p>I am taking a DDD approach to modelling this and using the Repository pattern for persistence.  However, I don't grok the pattern well enough yet to determine how I should do this.</p>
  
  <p>I'm working on the assumption that Editor and Project are potentially in the same aggregate, with the root being Editor.  I can therefore get an Editor and then enumerate its Projects, and could from there enumerate the Projects' member Editors.</p>
  
  <p>However, if I am only allowed to retrieve Editors from my repository, doesn't this mean I have to load all the Projects from the repository when I get the Editor that owns them?  And if I want to lazy load the member Editors, the Project needs a reference to the repository as well?</p>
  
  <p>Alternatively, if I split the aggregate and have an Editor repository and a Project repository, how should I handle a transaction across the two, such as when a new Project is added to an Editor?  For example:</p>
  
  <pre><code>Editor e = new Editor("Editor Name");
  editorRepository.Add(e);
  
  Project p = e.CreateProject("Project Name");
  projectRepository.Add(p);    // These two lines
  editorRepository.Save(e);    // should be atomic
  </code></pre>
  
  <p>Am I misinterpreting the intent of the Repository pattern?</p>