2
votes

I have 2 aggregates, which have kind of 1-to-many relationsip. For example, I have a list of questions, and I want to add some of them to questonaires, some of them are mandatory and must be added to all questionaires, some of them are not, and the creator of the questionaire choses them.

Let's say I am using event sourcing and CQRS. I create the list of questions, and I want to add the mandatory questions to the questionaire. Normally I would do

questionaire.AssignQuestions(questions.Where(q => q.isMandatory).Select(q => q.Id))

something similar. But in CQRS I shouldn't use the query model for this. But in the command model I am using event store, so I would have to replay all events on all questions, and that doesn't seem to be reasonable.

Most probably my model is not event oriented enough, but I don't really have a better idea at this point. How should I model this?

thanks

1
Is adding mandatory questions a user action or a rule that occurs at some point in the Questionnaire lifetime? If so, during which state transition does it happen?guillaume31

1 Answers

1
votes

You command handler can query a read model to retrieve the list of the question ids to form the questionaire.

But in CQRS I shouldn't use the query model for this.

This is just a false myth