문제

I'm looking for the right way of communicating the current version of my Aggregate to the Read Model. Currently the only possibility I see is to do the following:

public class Child : AggregateBase
{
    ...

    public void ChangeName(string firstName, string lastName)
    {
        RaiseEvent(new ChildNameChanged(Id, Version + 1, firstName, lastName));
    }

    ...
}

I don't like it because I think the Aggregate should dispatch the AR version automatically to all the read side event handlers.

Are there other ways I could do this?

도움이 되었습니까?

해결책

Have a look at this gist from JOliver himself: https://gist.github.com/1311195

Basically what he does is that he attach the version as a header in the dispatched message instead. You don't want to add stuff like that to your events. The events should be kept focusing on the business.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top