CQRS

Command Query Responsibility Segregation

CQRS is a development principle claiming that a method must be either a command that performs an action or a request that returns data.

To put it simply, every action in Web API is either a request (get data) or a command (put data), but it shouldn’t do both. Consequently, each API method is divided into requests and commands.

The main advantage of this approach is that get and put operations are separated. Why is that important?

The practice has shown that 90 percent of requests concern get operations; as a rule, they are small and quick. 10 percent of requests concern put operations; these operations are usually complicated due to a range of transactions and validations.

Last updated