Skip to content

Instantly share code, notes, and snippets.

@yreynhout
Created August 16, 2013 10:13
Show Gist options
  • Save yreynhout/6248727 to your computer and use it in GitHub Desktop.
Save yreynhout/6248727 to your computer and use it in GitHub Desktop.
public class ChildRepository {
public Optional<Child> GetOptional(string identifier) {
//Very simple parent-child example
var childStream =_streamReader.Read(identifier);
var parentId = ((SomeInitialEvent)stream.Events[0]).ParentId;
var parentStream = _streamReader.Read(parentId);
var root = new Child();
root.Initialize(parentStream.Events);
root.Initialize(childStream.Events);
return new Optional<Child>(root);
//there's no limit to how one can weave together various streams
//and use that union to build up the state of a particular aggregate
//not only can one vary along the 'multiple classes per stream' axis
//but also along the 'multiple streams per class' axis
}
}
@ToJans
Copy link

ToJans commented Aug 16, 2013

KISS! I like it!

@yevhen
Copy link

yevhen commented Aug 17, 2013

This is great, if you don't mind some of the infrastructure, leaking into the domain layer ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment