Facilitating the spread of knowledge and innovation in professional software development



Choose your language

InfoQ Homepage News New C# based CQRS Tutorial available

New C# based CQRS Tutorial available

This item in japanese

Lire ce contenu en français


A new CQRS, Command Query Responsibility Separation, Starter Kit to help developers get up and running with CQRS on .NET has been developed and made available as open source by Jonathan Worthington and Carl Mäsak.
The two developers notes that this is not a framework, it’s a “bunch of C# code” meant as a tutorial for developers interested in learning about CQRS, and as a possible starting ground for a CQRS based system, in which case you will change the code to fit your needs.

The tutorial code is an application in the cafe domain focusing on the concept of a tab which tracks the visit of an individual or group to the cafe. The tutorial itself is divided into five steps starting with design, domain logic and read models followed by integration into an ASP.NET MVC web application.
In the tutorial, Jonathan and Carl also bring up a few points to consider, e.g. regarding transactions and eventual consistency, if you want to extend the example to a production system.

Jonathan and Carl emphasizes that unless you are in a learning phase, you shouldn’t start with CQRS because it’s the new modern thing, instead you should arrive at this decision because of your architecture goal:

I want to work in terms of commands/events for my domain logic, because modelling and writing tests this way will help me deliver a system that meets the customer's needs. I want to persist using an event store, but that doesn't meet my querying needs. Therefore, I need to also have a relational database. This means my reads and writes need to happen through different code paths, which means I will be doing CQRS.

CQRS is an architectural pattern receiving an increasing interest. The DDD community website, maintained by among others Eric Evans, specifically notes the importance:

CQRS & Event Sourcing are two closely related architectural approaches to DDD and they are the hottest topics in DDD of the last couple of years.


We need your feedback

How might we improve InfoQ for you

Thank you for being an InfoQ reader.

Each year, we seek feedback from our readers to help us improve InfoQ. Would you mind spending 2 minutes to share your feedback in our short survey? Your feedback will directly help us continually evolve how we support you.

Take the Survey

Rate this Article


Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p


Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.