O'Reilly logo

Implementing Domain-Driven Design by Vaughn Vernon

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Lambda Syntax

If your language supports lambda expressions, it is possible to make otherwise repetitive code more compact by avoiding repetitive Event Stream management. To demonstrate this fact, here we introduce a helper method within our Application Service:

public class CustomerApplicationService {   ...   public void Update(CustomerId id, Action<Customer> execute)   {     EventStream eventStream = _eventStore.LoadEventStream(id);     Customer customer = new Customer(eventStream.Events);     execute(customer);     _eventStore.AppendToStream(       id, eventStream.Version, customer.Changes);   }   ... }

In this method the parameter Action<Customer> execute references an anonymous function (C# delegate) that ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required