You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ReadMe.md
+5-6Lines changed: 5 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,6 @@ The **EventDriven.CQRS.Abstractions** library contains interfaces and abstract b
28
28
The **Reference Architecture** projects demonstrate how to apply these concepts to two microservices: `CustomerService` and `OrderService`. In addition, each service has *separate controllers for read and write operations*, thus segregating command and query responsibilities, with different sets of models, or Data Transfer Objects (DTO's).
29
29
-**Query Controller**: Uses repository to retrieve entities and converts them to DTO's with AutoMapper.
30
30
-**Command Controller**: Converts DTO's to domain entities using AutoMapper. Then hands control over to a command handler for executing business logic.
31
-
-**Command Broker**: Dispatches the command object to the correct command handler.
32
31
-**Command Handler**: Uses a domain entity to process commands which generate one or more domain events, then requests entity to apply the domain events in order to mutate entity state. Persists entity state to a state store and optionally publishes an integration event which is handled by another microservice.
33
32
-**Repository**: Persists entity state to a database.
34
33
-**Event Bus**: Used to publish integration events, as well as subscribe to events using an event handler. Dapr is used to abstract away the underlying pub/sub implementation. The default is Redis (for local development), but Dapr can be configured to use other components, such as AWS SNS+SQS.
@@ -88,9 +87,9 @@ The **Reference Architecture** projects demonstrate how to apply these concepts
88
87
89
88
1. Add **Domain** and **CustomerAggregate** folders to the project, then add a `Customer` class that extends `Entity`.
90
89
- Add properties representing entity state.
91
-
- Create commands that are C# records and extend an `ICommand` interface with the result type as the generic.
90
+
- Create commands that are C# records and extend a `Command` base class.
92
91
```csharp
93
-
public record CreateCustomer(Customer Customer) : ICommand<CommandResult<Customer>>;
92
+
public record CreateCustomer(Customer Customer) : Command.Create(Customer.Id);
94
93
```
95
94
- Create domain events that extend `DomainEvent`.
96
95
```csharp
@@ -113,7 +112,7 @@ The **Reference Architecture** projects demonstrate how to apply these concepts
113
112
- Inject `ICustomerRepository`, `IEventBus` and `IMapper` into the ctor.
114
113
- In the handler for `CreateCustomer`, write code to process the command, apply events, and persist the entity.
115
114
```csharp
116
-
public async Task<CommandResult<Customer>> Handle(CreateCustomer request, CancellationToken cancellationToken)
115
+
public async Task<CommandResult<Customer>> Handle(CreateCustomer command)
@@ -138,7 +137,7 @@ The **Reference Architecture** projects demonstrate how to apply these concepts
138
137
```
139
138
- In the `UpdateCustomer` handler, see if the shipping address has changed, and if so, publish a `CustomerAddressUpdated` integration event, so that the order service can update the shipping address in the customer's orders.
140
139
```csharp
141
-
public async Task<CommandResult<Customer>> Handle(UpdateCustomer request, CancellationToken cancellationToken)
140
+
public async Task<CommandResult<Customer>> Handle(UpdateCustomer command)
0 commit comments