Skip to content
Anrijs Vitolins edited this page Apr 19, 2021 · 10 revisions

Dapper.Cqrs

Code in this repository and NuGet package is CQRS (Command Query Responsibility Segragation) database data access and manipulation principle, implemented using Dapper MicroORM. It is built to ease database data manipulations for development, separating Queries from Commands, allowing to use it as the only approach or together with other ORMs as supporting.

Library uses Microsoft.Extensions.Logging to provide extensive logging on internal processes (depending on logging level) and can provide valuable information during debugging application.

As Dapper uses "magic strings" for database queries, package is built in a way it exposes these magic strings for testing against database engine (and defined structures).

Code is separated into (at least) two assemblies (packages):

  • Abstractions
  • Database-specific implementation(s)

Abstractions

Provide common interfaces and base functionalities suitable for all database engines. This package does not demand specific database client as dependency. It contains IQuery and ICommand interfaces as well as internal interfaces and implementation to employ Unit-of-Work database connection handling.

Database specific

(Currently only MS SQL) Classes and functionalities to work with database engine, handling its specific conection, opening, closing and transaction handling transparently for application using it.

Using

Register interfaces with implementation with dependency container of your choice. Then in your business logic code, inject ICommandQueryContext and use it to perform data queries and issuing data updates through it, like

var data = cqrs.Query(new SomeDataQuery(id));
Clone this wiki locally