Search code examples
c#design-patternsdomain-driven-designdomain-events

Domain event being executed after transaction completes. How to get the concrete type.


I wanted to publish a domain event after a transaction completes. So I have followed this article here: http://www.jayway.com/2013/06/20/dont-publish-domain-events-return-them/ and also had a look at this SO post: Should I Pass a repository to a Domain Method that fires an Event

Makes sense... but I am confused as to how to resolve the Interface collection to the concrete types. For example in the collection of IEvent there maybe 2-3 different types of events. How do I figure out which event was added to fire the correct handler?


Solution

  • I found the answer in the comment of the following post: http://lostechies.com/jimmybogard/2014/05/13/a-better-domain-events-pattern/ i.e.

    DomainEvents.Raise((dynamic) event)