---
# System prepended metadata

title: Design Pattern

---

---
type: slide
---

# Design Pattern

---

## CQRS
* Command Query Responsibility Segregation

![](https://i.imgur.com/WMzRZ4F.png)

---

## Domain-Driven Design(DDD)

![](https://i.imgur.com/e6qBB0T.png)

---

## Mediator 

![](https://i.imgur.com/IXnVn9c.png)

---

## ASP.NET Core API using MediatR

![](https://i.imgur.com/dvv1ny6.png)

---

## non-repository vs Repository vs Repository + UnitOfWork

![](https://i.imgur.com/0ByoCbD.png)


https://davidskyspace.com/unit-of-work-pattern-concepts-in-net/

---

## ASP.NET Core API using MediatR Example

* origin api
![](https://i.imgur.com/dK30wqx.png)

---

### MediatR

* Step1 Create Query
    * Create `Queries/GetAllOrdersQuery.cs`

![](https://i.imgur.com/kqZmV29.jpg)

---

* Step2 refactor api

![](https://i.imgur.com/ezuSW5k.png)

---

* Step3 Create Handlers

![](https://i.imgur.com/Spgsmx0.jpg)

---

### reference
* https://abdelmajid-baco.medium.com/cqrs-pattern-with-c-and-mediatr-part-2-2ded039b7f70

* https://www.youtube.com/watch?v=YzOBrVlthMk&ab_channel=NickChapsas

* https://ithelp.ithome.com.tw/articles/10216645

---