Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Query Endpoint Template

The API Template guides developers down the path of implementing CQRS for REST based endpoints, as discussed in Introduction to CQRS

The query template is a great option if you want to add an additional query option to your endpoints. This template works in a similar fashion to the Command Endpoint Template

To do so you can simply use

dotnet new query -n <name of your query> -o <Directory location to create> --namespace <Namespace you would like to use>  --resource <name of the resource>

Switches

  • -n Name of the Endpoint being created
  • -o the output directory you would like to create
  • --namespace The root namespace of your project i.e. Your company or project name
  • --resource the name of the resource the command will be associated too
  • --force This is an optional command which enables overwriting some or all of the folders associated with the command.

Example

In a similar example we defined in the Command Endpoint Template we want to create a Read endpoint in our Email API resource.

 dotnet new query -n Read -o SampleProject/Activities/Email --namespace SampleProject --resource Email

Which will result in a number of folders & files being created.

Query Created