Monday, November 29, 2021

Implement CQRS with MediatR in ASP.NET Core Web API

What is CQRS?

English Answer

CQRS (Command Query Responsibility Segregation) is a design pattern that separates write operations (Commands) from read operations (Queries). Commands modify data, while Queries only retrieve data.

বাংলা উত্তর

CQRS (Command Query Responsibility Segregation) হলো একটি Design Pattern যেখানে Write Operation (Command) এবং Read Operation (Query) আলাদা করা হয়। Command Data পরিবর্তন করে এবং Query শুধুমাত্র Data পড়ে।

What is the main goal of CQRS?

English Answer

The main goal of CQRS is to separate read and write responsibilities to improve scalability, maintainability, and performance.

বাংলা উত্তর

CQRS-এর প্রধান উদ্দেশ্য হলো Read ও Write Responsibility আলাদা করে Application-কে আরও Maintainable, Scalable এবং Performant করা।

English

Clean Architecture separates the application into Presentation, Application, Domain, and Infrastructure layers. Domain contains business entities and rules. Application contains CQRS commands, queries, handlers, DTOs, and use cases. Infrastructure handles EF Core, repositories, and external services. Presentation contains APIs and controllers. Dependencies always point inward, making the application maintainable, scalable, and testable.

বাংলা

Clean Architecture-এ Application-কে Presentation, Application, Domain এবং Infrastructure Layer-এ ভাগ করা হয়। Domain Layer-এ Business Rules ও Entities থাকে। Application Layer-এ CQRS Commands, Queries, Handlers এবং Business Logic থাকে। Infrastructure Layer Database ও External Services Handle করে। Presentation Layer API ও Controller নিয়ে গঠিত। Dependency সবসময় ভিতরের Layer-এর দিকে যায়, ফলে Application Maintainable, Scalable এবং Testable হয়।

What is MediatR?

English Answer

MediatR is a .NET library that implements the Mediator Pattern. It helps decouple Controllers from Handlers.

বাংলা উত্তর

MediatR হলো একটি .NET Library যা Mediator Pattern Implement করে এবং Controller ও Business Logic-এর মধ্যে Decoupling তৈরি করে। 


https://www.youtube.com/watch?v=bgoGtkmUAQg
https://www.youtube.com/watch?v=T1qyGmdgSQE
The Command and Query Responsibility Segregation(CQRS) is an architectural pattern that separates the read and writes operations of a data source
Mediator is used to reduce communication complexity between multiple objects or classes. This pattern provides a mediator class which normally handles all the communications between different classes and supports easy maintenance of the code by loose coupling. Mediator pattern falls under behavioural pattern category.
 
Basically, a Mediator perform 2 operations.
  • · Accept the incoming request
  • · Handles the incoming request and provide the response.
CQRS Mediator Patterns are prefered over large projects.

Advantages of CQRS

  1. Independent scaling
  2. Optimized data transfer objects
  3. Provides separation of concern
  4. High scalability

 





No comments:

Post a Comment

Project OverView

 21H_LeakTesting   DashPerm  EWI_Assembly APQP Management System DynaShippingPortal KitValidation DAVIE API Guided Picking 21H_LeakTesting W...