Command Query Separation for 🌐ASP.NET Core ⚡AWS Lambda ⚡Azure Functions ⚡Google Cloud Functions
Command Query Separation (CQS) for .NET and C#
Available for:
🌐 ASP.NET Core
⚡ AWS Lambda
⚡ Azure Functions
⚡ Google Cloud Functions
🌐 ASP.NET Web API 2
Command Query Separation?
Queries: Return a result and do not change the observable state of the system (are free of side effects).
Commands: Change the state of a system but do not return a value.
In other words:
The traditional approach that commands do not return a value is a bit inconvenient.
CommandQuery
has a pragmatic take and supports both commands with and without result 👍
CommandQuery
⚙️Command Query Separation for .NET
CommandQuery.AspNetCore
🌐Command Query Separation for ASP.NET Core
CommandQuery.AWSLambda
⚡Command Query Separation for AWS Lambda
CommandQuery.AzureFunctions
⚡Command Query Separation for Azure Functions
CommandQuery.GoogleCloudFunctions
⚡Command Query Separation for Google Cloud Functions
CommandQuery.Client
🧰Clients for CommandQuery APIs
CommandQuery.AspNet.WebApi
🌐Command Query Separation for ASP.NET Web API 2
⛔ This package is no longer maintained and new versions will not be published
⬆️ Upgrading from version
1.0.0
to2.0.0
Upgrade command/query handlers:
net461
netstandard2.0
or greaterCancellationToken
parameter to the HandleAsync
methods in classes that implement ICommandHandler<TCommand>
, ICommandHandler<TCommand, TResult>
and IQueryHandler<TQuery, TResult>
Upgrade AspNet.WebApi:
CommandQuery.AspNet.WebApi
to CommandQuery.AspNetCore
Upgrade AspNetCore:
netcoreapp3.1
or net5.0
AddCommandControllers
and AddQueryControllers
in Startup.cs
Upgrade AWSLambda:
netcoreapp3.1
CommandFunction
and QueryFunction
from Handle
HandleAsync
HandleAsync
methods from ILambdaContext
ILambdaLogger
AddCommandFunction
and AddQueryFunction
on IServiceCollection
JsonSerializerOptions
constructor argument in CommandFunction
and QueryFunction
to configure JSON serialization/deserializationUpgrade AzureFunctions:
netcoreapp3.1
or net5.0
CommandFunction
and QueryFunction
from Handle
HandleAsync
AddCommandControllers
and AddQueryControllers
in Startup.cs
/Program.cs
CancellationToken
argument on HandleAsync
methods in netcoreapp3.1
projectsJsonSerializerSettings
/JsonSerializerOptions
constructor argument in CommandFunction
and QueryFunction
to configure JSON serialization/deserializationUpgrade Client:
CommandClient
and QueryClient
from Post
PostAsync
and from Get
GetAsync
AddHttpClient
extension method on IServiceCollection
to create the CommandClient
and QueryClient
(see sample)CancellationToken
argument to methods in CommandClient
and QueryClient
Validation:
AssertConfigurationIsValid
method on CommandProcessor
and QueryProcessor
to validate handler and type configurationInspired by Steven van Deursen blog posts: