Nice example, I like how the ICommand and IQuery markers are used just to drive pipeline behavior. Curious if Spyros ran into any friction later when adding more cross cutting concerns.
How I Built a CQRS Approval Flow with MediatR, Carter, FluentValidation, and SQLite
SpyrosLeader
posted
3 min read
1 Comment
Spyros
•
@[Ben Kiehl]
MediatR uses the same base interface (IRequest) for both commands and queries. At first it looks like it breaks the separation, but in practice it doesn’t violate Single Responsibility, because IRequest is just a transport contract.
In my case, the ICommand and IQuery markers are only there to drive pipeline behavior. For example, in TransactionBehavior I wrap only commands in a transaction, then commit when the command completes successfully. Queries skip that behavior completely.
Please log in to add a comment.
Please log in to comment on this post.
More Posts
- © 2026 Coder Legion
- Feedback / Bug
- Privacy
- About Us
- Contacts
- Premium Subscription
- Terms of Service
- Refund
- Early Builders
chevron_left
More From Spyros
Related Jobs
- Data Engineer (ADF/Data Flows & Snowflake) - Data Engineer 1 of 2Voluble Systems LLC · Full time · Prairie, MS
- Front-End Web Developer (Webflow)Macpower Digital Assets Edge · Full time · United States
- Full Stack Java/Go Developer (Bilingual English/Spanish)Dev Technology · Full time · Arlington, VA
Commenters (This Week)
abarth23
4 comments
István Döbrenteiverified
1 comment
Methodox
1 comment
Contribute meaningful comments to climb the leaderboard and earn badges!