Results 1 to 1 of 1
Sep 21, 2011, 13:13 #1
Performing queries against collections in aggregates.
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/3...506633#7506633 scroll down to end for my question.
Now, to restate this, in case you don't feel like going there.
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?