Since I cannot seem to login to the Yahoo DDD group at the moment, I have no choice but to ask here and at stack overflow.
http://stackoverflow.com/questions/3162495/traversing-aggregates/7506633#7506633 scroll down to end for my question.
Now, to restate this, in case you don't feel like going there.
[TD="class: answercell"]I have the following aggregate:
ExamSession -> ExamResponse
Now, if I have code like (c#):
var examSession = _examSessionRepository.Get(examSessionId);
Where ExamSession.RecordResponse looks like:
public virtual void RecordResponse(int questionId, int choiceId)
// input checking omitted here
Func<ExamResponse, bool> selector = x => x.QuestionId == questionId;
Then I have a problem. If I encapsulate the response by making questionId private, I cannot make linq queries against it. If I make it public read, it breaks encapsulation, even though I am not exposing the response itself.
DDD conventions say to expose only the Id property (for use with repositories), keeping the rest private. But how is one supposed to perform queries outside the repository if things are hidden?
What is the best way to handle this?