CQRS is a pattern for handling data: the Command Query Responsibility Separation. see: Wikipedia
- Command: unit of work which writes to one or more data sources (may also read from one or more data sources)
- Query: unit of work which reads from one or more data sources (should not write to any, except logging, if necessary)
- Executor: logical construct which executes one or more commands and or queries
- Define commands and / or queries by defining new classes which derive from
Command<T>orQuery<T> - You must override the
Executemethod in your derived class. The logic within there must, if possible, set theResultproperty on the command or query it belongs to - You may override the
Validatemethod in your derived class. Command/Query executors will run this logic before attempting toExecute. Any exception thrown within theValidatemethod will prevent command / query execution. - Execute commands with an instance of
CommandExecutor. Execute queries with an instance ofQueryExecutor - You must configure the behavior of Codeo.CQRS with
Fluently.Configure()- You must at least specify a connection factory with
WithConnectionProvider - You may register Sql mappings via the
WithEntitiesFrommethod, though this is optional: unknown entity types will be registered on fist use - You may register exception handlers via the
WithExceptionHandlermethod- if your exception handler is invoked and does not throw, the default value for the queried type is returned
- if your exception handler throws, that exception bubbles up
- if there is no exception handler for the type of exception which is caught by an executor, it bubbles up
- You must at least specify a connection factory with
See TestQueryExecution.cs for examples