0Pricing
C# Academy · Lesson

CQRS Concepts

Split commands from queries for clarity.

What Is CQRS?

CQRS stands for Command Query Responsibility Segregation. The idea is simple: separate the code that changes state (commands) from the code that reads state (queries).

// Commands : change state, return little or nothing
// Queries  : return data, change nothing

Commands

A command expresses an intent to change the system - create an order, cancel a subscription. It is named imperatively and typically returns only an id or nothing.

public record CreateOrderCommand(int CustomerId, string[] Items);
public record CancelOrderCommand(int OrderId);

All lessons in this course

  1. CQRS Concepts
  2. Commands and Handlers with MediatR
  3. Pipeline Behaviors
  4. Notifications and Events
← Back to C# Academy