CQRS – Command Query Responsibility Segregation
Problem
State data in traditional applications is represented through a set of entities. The entities are stored in a single data repository against which two types of operations can take place.
- Commands: Operations that modify state
- Queries: Operations that read state
An operation cannot both update state and return data. This distinction of operations helps simplify understanding the system. The segregation of operations into commands and queries is called the Command Query Separation (CQS) pattern. The CQS pattern requires the commands to have void return type and the queries to be idempotent.
If a relational database such as SQL Server is used for storing state...