-
Book Overview & Buying
-
Table Of Contents
High-Performance Programming in C# and .NET
By :
In this section, we will look at the Command Query Responsibility Separation (CQRS) design pattern. In simple terms, a command is a method that performs an action, while a query is a method that returns data. Commands do not perform queries, and queries do not perform commands. Commands can have separate models for queries. Now, let’s write a simple console application that demonstrates how easy it is to implement this pattern, which is used extensively in microservice development:
CH13_CQRSPattern.CQRSBasedClass.SleepCommand method:public void SleepCommand(int milliseconds)
{
Thread.Sleep(milliseconds);
}Our SleepCommand method is an example of a command. It takes in a parameter that is several milliseconds in length. A command is then executed that causes the current thread to sleep for the number of milliseconds specified...