I'm currently in a situation where I'm replacing the domain layer of an application but must retain the existing MVVM UI. We definitely want an event store, but I'm struggling with some aspects of our current CQRS implementation.
We have some complex aggregates that contain multiple entity collections and key/value pair dynamic attributes. Our existing UI has one large edit screen for this aggregate and I'm not sure how to structure the command(s) for the update.
Possible solutions:
1) Simply fetch the aggregate in the ViewModel, perform the updates against the domain model, and ship it with the command (var command = new SaveAggregateCommand(myAggregate);
). This feels wrong as the internal events would not be retained if shipping this across a serialized boundary (without custom serialization).
2) Create one complex command object that contains a list up updated attributes and separate lists of added, updated and removed child entities of each collection type. This would be the easiest for the command handler to work with but feels very sloppy.
3) Create many commands that basically mirror the domain model's events that get captured (there would be up to 38 in my scenario). The view model would then have to keep a list of uncommitted commands that get submitted when the save button is pressed by the user. Like #2, this also feels hacky.
Due to the (necessary) complexity of this aggregate, none of these solutions feel right. I would live some guidance on this one.