gautema/CQRSlite

IEvent Interface Question

GoneFishern opened this issue · 1 comments

Just starting out with CQRS concepts and implementation so I am still learning how all this fits together. My current understanding of events is that they should be immutable. Doesn't having IEvent implement {set;} on each of the properties mean that an event is mutable by definition or does that come down to the implementation of the event itself.

public interface IEvent : IMessage
    {
        Guid Id { get; set; }
        int Version { get; set; }
        DateTimeOffset TimeStamp { get; set; }
    }

Hi. Sorry for the late answer, but I've been away for the holidays.

You are correct that the events should be immutable and that a setter on the events makes them mutable which is not ideal. The setters are however necessary for the framework to be able to make sure id, version and timestamp is set and correct. While this may not be ideal, the important thing is to make sure the event store never changes a saved event.