See a root of the polymer:
public class ExampleAggregate : AggregateRoot<ExampleAggregate, ExampleId>, IEmit<ExampleEvent> { private int? _magicNumber; private int NameExample; public ExampleAggregate(ExampleId id) : base(id) { } // Method invoked by our command public IExecutionResult SetMagicNumer(int magicNumber,int n) { if (_magicNumber.HasValue) return ExecutionResult.Failed("Magic number already set"); Emit(new ExampleEvent(magicNumber, n)); return ExecutionResult.Success(); } // We apply the event as part of the event sourcing system. EventFlow // provides several different methods for doing this, e.g. state objects, // the Apply method is merely the simplest public void Apply(ExampleEvent aggregateEvent) { _magicNumber = aggregateEvent.MagicNumber; NameExample = aggregateEvent.NameExample; } }
Implements IEmit interface,
EMIT (new new ExampleEvent (magicNumber, the n-)); when the execution of this sentence,
it will trigger the execution of the field events