MediatR and CQRS for basic logic
So started doing abit of MediatR CQRS pattern in abit of Clean Architecture. I've been doing the Query and Commands for Database / API stuff as the articles suggest but what about general business logic?
Say I have a List of People and I want to capitalize all their Surnames right so Wibbly Wobbly becomes Wibbly WOBBLY and find people aged 30 and above.
Would it be:
ToCapitalSurnameAndOver30
simply takes a list foreach person in people
, gets the surname ToUpperCase()
and if (person.Age > 30)
add to another list maybe.
Nothing fancy but using _mediator.Send()
to get to this logic
or:
As you might find with most stuff.
In other words, should you use it for the majority of logic or just API/Database stuff.3 Replies
I'd have a query that specifically gets the people that meets my task and returns them in the appropriate manner.
So if that is a specific task my system needs to do, I'd have a
GetPeopleOver30Query
which gets and transforms the people directly in that query instead of passing it around, pulling information that isn't requiredwhat would the advantage of MediatR be in this case?
Great thanks 🙂