Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jfollmann/poc-dotnetcore-cqrs
https://github.com/jfollmann/poc-dotnetcore-cqrs
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/jfollmann/poc-dotnetcore-cqrs
- Owner: jfollmann
- Created: 2024-03-21T02:50:49.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-03-21T12:33:35.000Z (9 months ago)
- Last Synced: 2024-03-22T04:29:04.655Z (9 months ago)
- Language: C#
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# .netCore - CQRS
Create new webapi with controllers:
```sh
dotnet new webapi --use-controllers --framework net8.0 -n poc-dotnet-cqrs
```## Types of Lifetime (Dependency Injection)
| Type | Same Request | Other Request |
|-----------|------------------|----------------------|
| Singleton | Same instance | Same instance |
| Scoped | Same instance | New instance |
| Transient | New instance | New instance |Restore packages
```sh
dotnet restore
```Clean project
```sh
dotnet clean
```Build project
```sh
dotnet build
```Run project
```sh
dotnet run
```Get customer by uuid
```sh
curl -X GET \
http://localhost:5227/api/Customer?Id=0e60b197-53e8-4cd7-b536-c8a7b137902b | jq
```Create new customer
```sh
curl --header "Content-Type: application/json" \
-X POST \
-d '{"Name": "Customer Sample", "Email": "[email protected]"}' \
http://localhost:5227/api/Customer | jq
```References:
- https://balta.io/blog/aspnet-core-cqrs-mediator
- https://stackoverflow.com/questions/75527541/could-not-load-type-mediatr-servicefactory
- https://pt.stackoverflow.com/a/528207