Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Hands-On Domain-Driven Design with .NET Core

You're reading from   Hands-On Domain-Driven Design with .NET Core Tackling complexity in the heart of software by putting DDD principles into practice

Arrow left icon
Product type Paperback
Published in Apr 2019
Publisher Packt
ISBN-13 9781788834094
Length 446 pages
Edition 1st Edition
Languages
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
Alexey Zimarev Alexey Zimarev
Author Profile Icon Alexey Zimarev
Alexey Zimarev
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. Why Domain-Driven Design? FREE CHAPTER 2. Language and Context 3. EventStorming 4. Designing the Model 5. Implementing the Model 6. Acting with Commands 7. Consistency Boundary 8. Aggregate Persistence 9. CQRS - The Read Side 10. Event Sourcing 11. Projections and Queries 12. Bounded Context 13. Other Books You May Enjoy

Projections and Queries

In Chapter 9, CQRS - The Read Side, we changed our application to use events as the consistent aggregate storage. Instead of updating a snapshot of the state after handling a command, we can add new events to the stream that represents a single aggregate. We can then do a left fold on those events to reconstruct the aggregate state each time we load it again, before handling another command. In two lines of pseudo code, the essence of Event Sourcing can be represented as follows:

// Loading:
state = foreach(event in history: state = when(state, event))

// Command handling:
event = handle(state, command)

Here, history is what we load from the aggregate stream, when is the AggregateRoot.When method and Handle is one of the methods in the application service.

But, as I mentioned before, I removed all read models and the code associated with queries from the...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime