Code Monkey home page Code Monkey logo

cqrsandmediator-scaffolding's Introduction

CQRS and Mediator Scaffolding

Nuget

Medium article

CQRS & Mediator Part 2: Domain scaffolding with Roslyn API and Dotnet CLI in this part we will be building a dotnet CLI tool which follows the CQRS and Mediator patterns to auto generate commands, queries, responses and handlers in the domain layer using Roslyn API for code generation.

Breakdown of concepts and commands

Show help information:

scaffold -h

Command Parameters:

Concern: Name of the domain area you are working in i.e Orders, People, Invoice ect.

-c|--concern <NAME>

Operation: Name of the action you are taking in your concern i.e GetById, GetPagedResult for queries or Create, Patch, Update for commands.

-o|--operation <OPERATION>

OperationType: The type of CQRS operation you are scaffolding i.e command or query

-ot|--operationtype <TYPE>

GroupBy: Specify how to group the domain actions. Either by concern or operation: Group domain objects by [C] for concerns or [O] for operations, defaults to concerns

-g|--groupBy <TYPE>

By concern: i.e group by concern when parameters are -c Orders -o GetById -ot query


| YourDomainLayer
    | Orders
        | Handlers
            | OrdersGetByIdHandler.cs
        | Responses
            | OrdersGetByIdResponse.cs
        | Queries
            | OrderGetByIdQuery.cs

By operation i.e group by operation when parameters are -c Orders -o GetById -ot query -g O

| YourDomainLayer
    | Handler
        | OrdersGetByIdHandler.cs
    | Responses
        | OrdersGetByIdResponse.cs
    | Queries
        | OrderGetByIdQuery.cs

Installation

Install using dotnet cli:

dotnet tool install --global CQRSAndMediator.Scaffolding

To uninstall use:

dotnet tool uninstall cqrsandmediator.scaffolding --global

Usage

Note: The tool requires that the project is setup already and that the actions are executed in the top level directory of where your domain layer directory is located.

Use case scaffold out the CRUD domain for an invoice:

The Create Command

scaffold -c Invoices -o Create -ot command

The Get By id query

scaffold -c Invoices -o GetById -ot query

The Patch Command

scaffold -c Invoices -o Patch -ot command

Develop locally

Update the nuget package version located in CQRSAndMediator.Scaffolding.csproj

dotnet build .
dotnet pack

then in the solution directory:

dotnet tool update -g cqrsandmediator.scaffolding --add-source ./nupkg --version x.x.x

cqrsandmediator-scaffolding's People

Contributors

armandj77-zz avatar armandjordaan77 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.