No video

Intro to MediatR - Implementing CQRS and Mediator Patterns

  Рет қаралды 222,843

IAmTimCorey

IAmTimCorey

Күн бұрын

Пікірлер: 551
@brandonpearman9218
@brandonpearman9218 3 жыл бұрын
Been working with CQRS and mediatr for years now, and from my experience it generally makes complex systems more complex. The need for CQRS or mediatr is generally not needed but many devs use it everywhere because its a shiny new pattern.
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
I can see that. It is a pattern that really should be reserved for larger projects and specific circumstances.
@brandonpearman9218
@brandonpearman9218 3 жыл бұрын
@@madd5
@ejenkins132
@ejenkins132 2 жыл бұрын
It seems like one of the big benefits could be in unit testing. In many projects I work on, classes have a ton of dependencies that are injected through the controller. If we want to unit test one of these classes, we have to mock out each one of these dependencies and specify what each of their methods should return when called, which leads to a lot of boilerplate in the UTs. Using a single mediator in place of all those dependencies seems like it could remove a lot of that boilerplate. Of course, using a ton of dependencies in your classes also seems like a bad smell, so maybe that should be addressed prior to considering CQRS? :shrug:
@brandonpearman9218
@brandonpearman9218 2 жыл бұрын
@@ejenkins132 yeah, at first glance it does seem ut will be easier but working on both styles i dont notice the difference. Even in the case where you have a ton of extra dependencies it shouldnt be an issue in ut. There are a few solutions you could use. 1. Pass in null for dependencies not used(assuming you dont have null check because container does that). 2. Have a single location where you construct your class with default mocks but not stating what it returns. Then in each test set what the relevant dependencies return. 3. I built my own auto inject mocks in ut which was an idea iv been testing and it is working quite well because i never have to even consider a classes dependencies in ut (only what they should be returning for a given test)
@brandonpearman9218
@brandonpearman9218 2 жыл бұрын
@@ejenkins132 i was recently told to convert a certain project to mediatr. It took a small project and made it a big one. It over 10x the amount of files. the bloat is so disgusting and with the inability to goto a calling method, navigating this project and understanding what it does is so difficult now. But if I had to show you a single handler, you could say that its simple because it does one thing, and thats where the trap is. Simple when dealing with a handful of handlers.
@georgesaeid7231
@georgesaeid7231 7 ай бұрын
This is the most elegant explanation of MediatR ever. Thank you.
@IAmTimCorey
@IAmTimCorey 7 ай бұрын
You are welcome.
@Rondalaquanaynay
@Rondalaquanaynay 2 жыл бұрын
Hey Tim, Like 7 months ago I finished an expensive bootcamp that.... taught me very little. I then signed up for your master class and completed it fully, A week after completing the masterclass got 2 very nice competing engineering offers. And here I am, today marks 1 month at my first engineering job AND my job happens to use Mediatr which you have now helped me understand perfectly. You da best. lol thanks again -Ron
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
Fantastic! Thanks for sharing.
@bardus_hobus
@bardus_hobus 2 жыл бұрын
Tim, I want to say thank you for all your videos. I have finally landed my first job as a software developer, and I owe it in part to your amazing training. I am now going back through your videos to review some stuff they use (such as MediatR) for my continued education. Thank you so much for helping me reach my dream job!
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
Awesome! I am glad my content was so helpful. Congratulations on the new job!
@user-sy5fd7kn8w
@user-sy5fd7kn8w Жыл бұрын
Your job is your own credit, no amount of videos would have helped if you didn't apply effort and perseverance. Tim does great job, but remember that no matter how great of a job he does, you would not be affected without doing all the work yourself. I hope you feel happy at your job and satisfied with your career.
@RubenALopes
@RubenALopes Жыл бұрын
I know that feeling, everytime something new comes up at work like this, I search Tim's channel and there it is: an extensive video explaining that topic like this one. Stay strong to keep learning and thanks Tim for making it a bit easier
@sayedraminSadat
@sayedraminSadat 3 жыл бұрын
Learned amazing staff today. Thank you Tim. I would love to see part 2 with advance MediatR implanted in complex application.
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
I will add it to the list. Thanks for the suggestion.
@Keiktu
@Keiktu 3 жыл бұрын
@@IAmTimCorey Please do so! This video helped me out to have a very solid understanding of these patterns.
@katekko1
@katekko1 3 жыл бұрын
@@IAmTimCorey Waiting for it too
@karthick8334
@karthick8334 2 жыл бұрын
@@IAmTimCorey Also do a video on MediatR Publish on top of this demo.
@kpg7882
@kpg7882 2 жыл бұрын
@@IAmTimCorey How it's going? ;-)
@roaba3581
@roaba3581 3 жыл бұрын
Easily the most understandable explanation I have seen. Totally worth to watch the 1,5 hours instead of a few shorter vids that don't really deliver the whole picture.
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 3 жыл бұрын
Excellent point and thanks for sharing and spending the 1.5 hrs with Tim.
@vatansoni6439
@vatansoni6439 3 жыл бұрын
28:13 mediator 31:58 Query > IRequest 34:10 Handler > IRequestHandler
@manuelapostol7664
@manuelapostol7664 2 жыл бұрын
Thanks. Too much information when you only want to know about mediator
@enfissione8297
@enfissione8297 2 жыл бұрын
1.5 speed, very watchable and saves a lot of time.
@masygoli2831
@masygoli2831 2 жыл бұрын
It was one of the useable tech videos I've ever seen in KZbin with simple yet powerful teaching ability. Thanks a lot!
@stefan263
@stefan263 2 жыл бұрын
Thanks for the effort putted, I appreciate! Also I am following you since more than 3 years. What you covered is great and the explanation as well. What I will state, is not related to this video but to the over use of this pattern. In my experience, 7 years now, I saw lately an over use of this pattern which leads to lots and lots of complexity which leads to technical debts and also bugs. Do not call another handler inside another one is bad design. If you are in the need of doing such thing then change your design. Make a XService for your XController, and let that service handling your flow. If you still want to use mediator, just inject it in the XService and call in the right order the handlers. Finally, the XMethod will be responsible to return/or not, the requested action. The benefits? Think about transactions, and much more, like SRP not violated, easy to test etc. To state that having many injected dependencies require mediator, is again, a naive approach. Why? Because we should fix the bad design of the code as easy as possible not by introducing a pattern which add heavy complexity. Also, if you are in a EDD structure, this will add another event pipeline which has to be maintained, upon many others like signalR, Masstransit with Rabbit etc. Maybe the reason of being too many dependencies injected in a class is due to the fact that SRP is violated and is doing too much, therefore it should being split by proper responsability. And much more can be said. Anyway, as last note, I just want to say that CQS which is somehow a CQRS, can be achieved without using the Mediator but just by separating responsabilities in Queries and Commands, at simple level speaking. Because real CQRS, implies a complex architecture/flow, like for example, Quries should have their own DB and so on.
@Keiktu
@Keiktu 3 жыл бұрын
Mr. Corey. This video is pure gold!! Thank you very much for this video, I have been looking into learning CQRS and MediatR for a while.
@FinallHit
@FinallHit 2 жыл бұрын
0:00 - Intro 1:01 - What is CQRS 3:49 - What is Mediator 9:00 - Mediator Pattern 12:00 - Create BlazorUI app 13:24 - Create DemoLibrary Class Library 15:25 - When should i implement MediatR? 19:22 - Setting up DataAccess class 25:10 - Setting up BlazorUI app 28:18 - Adding MediatR Package 28:48 - Build out MediatR Setup 29:08 - Setting up Queries 30:08 - Difference between Class and Record 30:51 - Setting up GetAll Query 33:33 - Setting up GetAll Handler 38:30 - Configure StartUp (BlazorUI) 43:21 - Inject and use MediatR in razor page 49:30 - Create DemoApi Web API 50:44 - Configure StartUp 51:52 - Create Controller 52:58 - Inject MediatR 53:26 - Implement HttpGet all 54:16 - Run DemoApi 56:27 - Setting up GetById Query 58:05 - Setting up GetById Handler 1:03:11 - Implement HttpGet by Id 1:04:28 - Run DemoApi 1:05:25 - Setting up Insert Command 1:08:55 - Setting up Insert Handler 1:10:34 - Implement HttpPost 1:12:38 - Run DemoApi 1:13:59 - Recap Thanks for the awesome content! Learned alot, Cheers!
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
Thank you!
@expertreviews1112
@expertreviews1112 10 ай бұрын
Best video on MediatR! Tim your way of teaching is the BESTTT
@IAmTimCorey
@IAmTimCorey 10 ай бұрын
Thank you!
@antoniomarcos5664
@antoniomarcos5664 Жыл бұрын
Hi, Tim. Great explanation! I have seen other developers getting a mess to explain clearly. How always your explanations bring us enlightenment. Thanks.
@IAmTimCorey
@IAmTimCorey Жыл бұрын
You are welcome.
@_rachid
@_rachid 3 ай бұрын
Currently I'm trying to learn how to build a .NET web api using Clean Architecture and I needed a cristal clear explanation of Mediator pattern, and thank God I found it on your youtube channel. I'm grateful to you Tim, thank you. Greetings from France.
@IAmTimCorey
@IAmTimCorey 3 ай бұрын
I am glad it was helpful.
@fadidib8516
@fadidib8516 2 жыл бұрын
Thx for showing both the record and the class way, easier to understand this way.
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
You are welcome.
@delroymiller2630
@delroymiller2630 Жыл бұрын
Tim, you did another excellent job breaking and explaining a topic that has challenged developers new to this tool and some of these concepts. Well done!
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Thank you.
@runtimmytimer
@runtimmytimer 3 жыл бұрын
Great timing. I just started a project that uses MediatR. Pretty cool stuff. Nice job on the explanation as well. They've implemented a generic handler class GenericHandler that abstracts away all the handler implementations. Interesting approach.
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 3 жыл бұрын
Thanks for sharing your real world experiences
@MegaMatroc
@MegaMatroc 11 ай бұрын
I just started with new project that uses Mediator library. This was whole new tool to me. So cool that you can bury business logic little deeper than what is usually in controller layer. Thank you for showing what is this pattern all about and how to implement it to project. Learned a lot and I feel like I'm able to understand this new project better now. Thank you very much for clear explanations. Much love
@IAmTimCorey
@IAmTimCorey 11 ай бұрын
You are welcome.
@androidsavior
@androidsavior 5 ай бұрын
cant believe I've finally used mediator, it turns out it's so easy :) Thank you very much
@IAmTimCorey
@IAmTimCorey 5 ай бұрын
You are welcome.
@DoubleDP007
@DoubleDP007 2 жыл бұрын
Hi Tim, the algorithm was useful this time round. So glad I found your channel. You are a natural born teacher, thanks for making things so easy to understand. Would be great if you could expand on this with some complexity including fluent validation, auto mapping and error handling in a clean architecture
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
Thanks for the suggestions.
@cymrucoder
@cymrucoder 2 жыл бұрын
Incredibly useful video. We're refactoring an existing API at my work using the Mediator Pattern in the coming weeks, and this has introduced the topic to me so well! Keep up the amazing work.
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
Glad it was helpful!
@kartheeknandini3767
@kartheeknandini3767 3 жыл бұрын
Long waiting ended. I am waiting for this. Thank you Tim
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 3 жыл бұрын
Thanks for hanging in there with us!
@hyunbinpark3382
@hyunbinpark3382 2 жыл бұрын
This lecture was so perfect for me to understand how enterprise app works in general. Thanks a lot.
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
You are welcome.
@mortezanejat8707
@mortezanejat8707 2 жыл бұрын
u actually make OUR life easier.
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
Great!
@PradeepSingh-ly5oq
@PradeepSingh-ly5oq 2 ай бұрын
Thank you Tim for creating such a wonderful Video.
@IAmTimCorey
@IAmTimCorey 2 ай бұрын
You are welcome.
@ericwagner2307
@ericwagner2307 2 жыл бұрын
I loved the whiteboarding at the beginning with the gradual transition into code. Walking away from this one feeling very comfortable reviewing a codebase using MediatR. Thank you as always Tim!
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
You are welcome.
@cotepatrice
@cotepatrice 3 жыл бұрын
Nice stuff for someone who wants a quick dive in the Mediator pattern, CQRS and the MediatR tool. Thanks!
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
You are welcome.
@LuisBragagnolo
@LuisBragagnolo 2 жыл бұрын
Tim, you are the best!!! You explain complicated topics very simple! Thanks!
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
You are welcome.
@torrvic1156
@torrvic1156 6 ай бұрын
Thank you, thank you so much great teacher Tim Corey! Thanks to you I finally understood how to use this shotgun to kill the fly. Also learned that Queries are for Read operations and Commands are for Create, Update, Delete operations (both implement IRequest) and all of them are served by Handlers (which implement IRequestHandler). And with the help of MediatR it’s possible to invoke Handlers via appropriate Commands and Queries. Also I learned about .FromResult method to convert to Task (I struggled with it before).
@IAmTimCorey
@IAmTimCorey 6 ай бұрын
You are welcome.
@nicklebeezy
@nicklebeezy 3 жыл бұрын
Lessons learned in CQRS and MediatR; I would avoid having commands call other commands. Tim showed this on the Query side which in most cases is probably fine, albeit not usually necessary (IMO). However, in implementing CQRS for the first time it's really tempting to have commands call other commands which in my experience is an anti-pattern you want to avoid (say for instance you are trying to follow DRY or the S in SOLID). If you feel the need to do this, a better solution would be use Domain Events, which comes from Domain Driven Design. In my experience, if your requirements or business logic are complex enough to grow beyond CRUD operations, it's likely that you'll be reaching for CQRS and MediatR as a stepping stone to DDD anyways. I haven't seen many use cases that justify using CQRS that don't then lead into DDD in my opinion. Otherwise, great intro Tim. I do enjoy using CQRS and MediatR and it certainly can make life more convenient.
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 3 жыл бұрын
Thanks for sharing from your experiences.
@Kattarhindusanatan22
@Kattarhindusanatan22 3 жыл бұрын
I would like to thank you for this great stuff.. I was afraid to watch such a big video but once I started time flies. And one more like for you haven't monetized the video it keeps the viewer focused. :) Thanks
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
You're very welcome!
@bullheadrider
@bullheadrider Жыл бұрын
Your explanation pattern is nothing but The best. God bless
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Thank you!
@Coeur85
@Coeur85 3 жыл бұрын
thank you time for the simple explanation , i watch a lot of videos about CQRS , none of them made sense till i watch yours :)
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Glad to hear that!
@paulpitchford
@paulpitchford Жыл бұрын
This really joined the dots up for me. Thank you.
@IAmTimCorey
@IAmTimCorey Жыл бұрын
You are welcome.
@davidpeck7131
@davidpeck7131 3 жыл бұрын
Great content Tim & team, as always, on the Mediator/MediatR intro. Would love to see this expanded on part 2 (advanced), with pipeline concepts to touch error handling or logging.
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
I will add it to the list. Thanks for the suggestion.
@mehdihosseini2442
@mehdihosseini2442 3 жыл бұрын
Thank you for your excellent and practical training. Surprise us with part 2 on how to properly use CQRS, mediator and saga in microservice.
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
I will add it to the list. Thanks for the suggestion.
@thehamzajunaid
@thehamzajunaid 6 ай бұрын
Thankyou so much. Covered so many aspects and was very easy to grasp.
@IAmTimCorey
@IAmTimCorey 6 ай бұрын
You are welcome!
@misterwoody_
@misterwoody_ 3 жыл бұрын
Many thanks Tim. Finally a video that covered reducing the dependency injection overload I was interested in, and how to put controllers on a diet. All the best.
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Glad it was helpful!
@blitzkidx
@blitzkidx Жыл бұрын
Thanks Tim, one of the best tutorials i've ever seen!
@IAmTimCorey
@IAmTimCorey Жыл бұрын
You are welcome.
@nadervaghari51
@nadervaghari51 2 жыл бұрын
wow! I really enjoyed watching this wonderful course. I appreciate the way you teaching and rectifying the problems. Thanks Tim 👍🙏
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
Glad you enjoyed it!
@brianbaldos
@brianbaldos 2 жыл бұрын
Simple and very easy to understand. Looking forward and wish for a separate video on how to unit test mediator handlers.
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
Thanks for the suggestion. Please add it to the list on the suggestion site so others can vote on it as well: suggestions.iamtimcorey.com/
@es7729
@es7729 6 ай бұрын
This video was awesome! I've to use this in my current project, never used it before. Now I know how and what! Thanks!
@IAmTimCorey
@IAmTimCorey 6 ай бұрын
You are welcome.
@thegaribovv
@thegaribovv Жыл бұрын
Tim, I really appreciate your tutorials quality
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Thanks!
@alickcampbell8915
@alickcampbell8915 10 ай бұрын
Great introductory video!
@IAmTimCorey
@IAmTimCorey 10 ай бұрын
Thanks!
@hannimedable
@hannimedable 3 жыл бұрын
Wow, that for sure will move some plans from the evening!
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Enjoy!
@hannimedable
@hannimedable 3 жыл бұрын
@@IAmTimCorey hope you also have something about event sourcing on your list :)
@yossrikhalil9551
@yossrikhalil9551 3 жыл бұрын
I would love to see some event sourcing tutorial as well
@alexsnegir1427
@alexsnegir1427 3 жыл бұрын
Great video! Thanks, Tim! I'll be glad to see some DDD concepts in practice. Aggregates, Entities, Value Objects, etc. Also some Event Sourcing, too.
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 3 жыл бұрын
Thanks for watching Alex.
@David-rz4vc
@David-rz4vc 3 жыл бұрын
Yeah, would be nice to see some of those
@joeyvico
@joeyvico Жыл бұрын
This was a master tutorial Tim. Excellent work. Thank you so much
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Glad you enjoyed it!
@alinazar7998
@alinazar7998 2 жыл бұрын
thanks for this very good intro to MediatR!
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
You are welcome.
@keyranjoshi10
@keyranjoshi10 3 жыл бұрын
I am really appreciate your efforts and time to make this video. Very detail and easy to understand. 👏👏👏
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Glad it was helpful!
@cristiancalichio5335
@cristiancalichio5335 2 жыл бұрын
Thanks Tim, very good explanation and introduction to the topic. It helped me a lot and was very concise! Greetings from Argentina!!!
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
Glad it was helpful!
@andrea-wc7fd
@andrea-wc7fd Жыл бұрын
Thank you very much from Argentina!
@IAmTimCorey
@IAmTimCorey Жыл бұрын
You are welcome!
@Kyogunaik
@Kyogunaik 3 жыл бұрын
With all of your videos, One day I’ll become a solution architect for sure😇
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Best wishes on your journey.
@Kyogunaik
@Kyogunaik 3 жыл бұрын
@@IAmTimCorey thank you so much 😊
@user-ci3pf5kc4z
@user-ci3pf5kc4z Жыл бұрын
Great video. Very easy and clear explanation of the CQRS and Mediator patterns! Just the practical stuff. Very nice point about balance as sometimes people tend to hyperbolize patterns :)
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Thank you!
@abdulrahmanalenezi620
@abdulrahmanalenezi620 2 жыл бұрын
Man you ARE THE BEST!! THANKS FOR THE AMAZING COURSE
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
You are welcome.
@vrajeshbadgujar
@vrajeshbadgujar 3 ай бұрын
Thanks Tim, for another great explanation! please cover tutorial for MediatR pipeline behavior.
@IAmTimCorey
@IAmTimCorey 3 ай бұрын
You are welcome.
@craigfreeman8225
@craigfreeman8225 3 жыл бұрын
Amazing that I was just watching a video on Onion architecture and trying to figure out why the application layer in the example used MediatR. Cant wait to watch this :D
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Great!
@pianoman1973
@pianoman1973 Жыл бұрын
Great and easy to understand presentation of the topic !
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Thanks!
@parsamh78
@parsamh78 4 ай бұрын
That's just what I need. Thanks a lot Mr. Corey ❤
@IAmTimCorey
@IAmTimCorey 4 ай бұрын
I am glad it was helpful.
@learner8084
@learner8084 2 жыл бұрын
Thank you very much, Tim. I find this video excellent.
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
You are welcome.
@vin2629
@vin2629 2 жыл бұрын
I absoluely loved this. I have a clear understanding of CQRS and how to implement it using MediaR. Howeever CQRS pattern can be used in many other ways especially while using microservices. Please create a dedicated video on CQRS
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
Thanks for the suggestion. Please add it to the list on the suggestion site so others can vote on it as well: suggestions.iamtimcorey.com/
@sbeasley1120
@sbeasley1120 3 жыл бұрын
Loved the content. I’ve been using MediatR for over a year now and I learned something new today. My only critique is you mentioned CQRS at the beginning then you lumped you commands and queries into the same api. And that doesn’t allow them to be independently scaled. I know it really wasn’t the point of this video. So a video on Behaviors and splitting up command and queries would be awesome
@pilotboba
@pilotboba 3 жыл бұрын
Yes, I would argue this isn't an example of CQRS as described by Greg Yong, because it doesn't have separate read and write models. But, this is a good example of CQS which has clearly separated the commands from the queries. Queries shouldn't have any side effects... you should be able to make the same query all day, and they don't change anything. While commands mutate things or have side effects.
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 3 жыл бұрын
I noted your recommendation by adding it to Tim's list of possible future topics, thanks.
@anrodse
@anrodse 3 жыл бұрын
Great video again. Thank you very much for all this work. Just two points that disturb me: 42:00 Create a new class (DependencyInjection?) at DemoLibrary project to extend IServiceCollection, adding a new method like AddDemoLibrary(this IServiceCollection services). Call services.AddMediatR() from there, using its own assembly (ie. DemoLibrary). 1:13:00 I would use InsertPersonCommand class as parameter. That way, people don't have to set an id to create a new person. An id which has no use anyway.
@RaihanTaher
@RaihanTaher 3 жыл бұрын
Thanks Tim for explaining things so clearly. You made the learning experience easy. Keep up the good work.
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
You are welcome.
@leosouza1520
@leosouza1520 2 жыл бұрын
Excelente explanation about the mediator pattern.
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
Thanks!
@niharprusty2801
@niharprusty2801 Жыл бұрын
excellent cool easy way of teaching. Thank you
@IAmTimCorey
@IAmTimCorey Жыл бұрын
You are welcome!
@MahmoudIsmail-rw7hg
@MahmoudIsmail-rw7hg Жыл бұрын
Thanks Tim, I like your explanation
@IAmTimCorey
@IAmTimCorey Жыл бұрын
You are welcome.
@bohuang3122
@bohuang3122 2 жыл бұрын
It's a wonderful teaching video. Thank for the sharing!
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
You are welcome.
@shahzshafie
@shahzshafie 3 жыл бұрын
i really enjoy this video.. simple to follow. Kudos Tim!! I (and i think many of the comments down below including myself) would love to learn more advance usage of these patterns, more so gearing towards the real enterprise systems. Thanks man... you are awesome!
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Glad it was helpful!
@junianohjj4602
@junianohjj4602 3 жыл бұрын
Hi Tim, great tutorial. I have been using MediatR and i like how my project is organized, especially simple API Controller routes. However I prefer having my Queries/Commands on same file with their corresponding Handlers for an easier lookup. Adding FluentValidation to MediatR makes it more powerful with how and when do handlers gets hit.
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Thanks for sharing.
@David-rz4vc
@David-rz4vc 3 жыл бұрын
I agree, having the handler be an internal class within the query or command files is useful for easy lookups. I like to have mine organized in features folders.
@GrigoryZhadko
@GrigoryZhadko 3 жыл бұрын
Hi. How do you pass information about User (ClaimsPrincipal) or HttpContext info to mediator? The original request class doesn't contain such information. Do you create additional class which looks almost the same as original request file but with additional User property?
@ismaelplaca244
@ismaelplaca244 2 жыл бұрын
Great video! Thanks Tim!
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
You are welcome.
@viktoralferov2874
@viktoralferov2874 3 жыл бұрын
Hi, My favourite package - MediatR. It allows you to make less coupled programm. Thumb Up I also use aliasing: using TRequest = RequestType using TResponse = ResponseType class SomeRequest: IRH + FluentValidation
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 3 жыл бұрын
Thanks for the recommendations
@viktoralferov2874
@viktoralferov2874 3 жыл бұрын
@@tomthelestaff-iamtimcorey7597 like this: namespace ... { using Request = RequestCommand; using Response = RequestCommand.Result; [DataContract] public class RequestCommand : IRequest { public string SomeProperty { get; set; } public class Validator : AbstractValidator { public Validator() { RuleFor(...) } } public class Handler : IRequestHandler { public async Task Handle(Request request, CancellationToken cancellationToken) { ... } } public class Result { public string SomeProperty { get; set; } } } } Sorry for code. If I should not do it here - just give me know that. Thank You (Tim).
@craigrichards5472
@craigrichards5472 3 жыл бұрын
Great walkthrough, your demo of Records was perfect 👍
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Glad you liked it!
@nnamacha
@nnamacha 3 жыл бұрын
Simply and Clear. Thanks Tim.
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
You are welcome.
@goodmanshawnhuang
@goodmanshawnhuang 2 жыл бұрын
wah, another amazing masterpiece from you Tim, thank you so much for sharing it, you are just the best!
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
You are welcome.
@meryemaydn8615
@meryemaydn8615 3 жыл бұрын
You are amazing Tim. Thanks a lot to you. You save me from a big deal. take care please. I will need your videos again :)
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
I am glad my content has been helpful.
@themagecan
@themagecan 3 жыл бұрын
Thanx Tim Thats Great Video Please continue This series 🙏
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
You are welcome.
@ItsAllAboutMusic92
@ItsAllAboutMusic92 3 жыл бұрын
Great Video! Thanks for that! Please make another one with more advanced topics!
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
I will add it to the list. Thanks for the suggestion.
@user-ou7of2lv7j
@user-ou7of2lv7j Жыл бұрын
at the first of the video i said oh my god what's going on 🤨but your explanations made things clear 👌 thanks
@IAmTimCorey
@IAmTimCorey Жыл бұрын
You are welcome.
@subbur4439
@subbur4439 3 жыл бұрын
Excellent video explains the concept very clearly
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Glad it was helpful!
@_grzehotnik
@_grzehotnik 3 жыл бұрын
I disagree that connecting CQRS and MediatR is a good choice, or at least not in tutorials. I see lots of .NET articles/tutorials for CQRS that use MediatR straight away from start. The problem is that MediatR in no way enforces CQRS, and the only bit of CQRS in such a solution is naming your objects differently. I don't know why .NET tutors like using the library for CQRS so much but this introduces more misconceptions that it solves problems, even simple stuff like using something like ICommandHandler in your controller is much more coherent and intuitive that using mediator to do your CQRS stuff. MediatR is good for mediator pattern and it should remain like this. I feel that this is another piece of software from Jimmy Bogard whose use case is misinterpreted (the other one being AutoMapper).
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
I think you missed part of the video. I did explain that MediatR (and CQRS and the Mediator pattern) is for more complex situations. That your application complexity has to get to a certain point before you add the complexity of MediatR to address the complexity. The difficult part is that I can't really simulate the complexity you would need before bringing in MediatR without making a VERY large video that mostly doesn't cover MediatR and that would leave you wondering at where the application left off and MediatR began. As for CQRS, MediatR is designed to work hand-in-hand with it and since you wouldn't implement MediatR until your application is complex enough to need it, your application will also be complex enough to need CQRS.
@timnguyen8190
@timnguyen8190 2 жыл бұрын
Thank you Tim, your explanation is great! Love it!
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
You are welcome.
@emersonstori
@emersonstori Жыл бұрын
thank you, your teaching is amazing😃😃😃
@IAmTimCorey
@IAmTimCorey Жыл бұрын
You are welcome.
@haizzengunn9350
@haizzengunn9350 3 жыл бұрын
Always a big fan of your videos,
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 3 жыл бұрын
Thank you for being a part of the community!
@wertrager
@wertrager 3 жыл бұрын
Excellent modern app architecture
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Thanks!
@DerekWelton
@DerekWelton 3 жыл бұрын
Great video Tim as always. I would recommend though that it wouldn't be best practice to call queries/commands within handlers as it will go through the mediator pipeline again calling all the behaviors causing more overhead (unless you purposely want it to go through that pipeline again)
@idowutosinmichael9120
@idowutosinmichael9120 Жыл бұрын
I dont understand this please
@TheSandoki
@TheSandoki Жыл бұрын
Great video, thank you a lot for great explanation!
@IAmTimCorey
@IAmTimCorey Жыл бұрын
You are welcome.
@apina1221
@apina1221 Жыл бұрын
for some reason my brain started to hear him as jayztwocents... now it won't go away...... :D
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Wait until you hear me rant about the cost of GPUs.
@wubblyjuggly
@wubblyjuggly 2 жыл бұрын
Excellent stuff I do love this pattern
@IAmTimCorey
@IAmTimCorey 2 жыл бұрын
Thank you!
@DrCox-xx8tu
@DrCox-xx8tu 3 жыл бұрын
Nice beginner tutorial for MediatR. Although I already was familiar with the things you showed, I really appreciate your work Tim. Could you maybe do a more advanced video on the additional features MediatR offers? For example validation, logging, exception-handling, ...
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 3 жыл бұрын
I noted your recommendation by adding it to Tim's list of possible future topics, thanks.
@andywalter7426
@andywalter7426 3 жыл бұрын
I would still love to see source generators covered. Because since reflection is too slow for webassembly and webassembly is getting more common for blazor, then source generators would be a good solution to avoid the performance penalty of reflection.
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
I will add it to the list. Thanks for the suggestion.
@anurag0304
@anurag0304 5 ай бұрын
"Wow, watching your video was like going from trying to understand rocket science to finally getting why the chicken crossed the road! Thanks for decoding the Matrix for us 😄🚀🐔
@IAmTimCorey
@IAmTimCorey 5 ай бұрын
I am glad it was helpful.
@ghufranullah3161
@ghufranullah3161 Ай бұрын
Great explanation....
@IAmTimCorey
@IAmTimCorey Ай бұрын
Thank you!
@RAZOR3181
@RAZOR3181 3 жыл бұрын
Hey TIM!!! That is a great video and helpful for Enterprise Applications...Thanks.
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 3 жыл бұрын
Thanks for watching
@huntersMoon01
@huntersMoon01 3 жыл бұрын
very nice... clear and to the point of subject
@IAmTimCorey
@IAmTimCorey 3 жыл бұрын
Thanks!
@d3tn3tracer
@d3tn3tracer Жыл бұрын
Thanks a lot Tím! 🙂
@IAmTimCorey
@IAmTimCorey Жыл бұрын
Thank you!
@jacool5168
@jacool5168 3 ай бұрын
Simple and clear
@IAmTimCorey
@IAmTimCorey 3 ай бұрын
I'm glad.
@mofidmoghimi581
@mofidmoghimi581 3 жыл бұрын
Thanks Tim. It's very useful. Please make a video about event sourcing.
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 3 жыл бұрын
Thank you. I have added this to Tim's list of possible future topics.
@aminebenhebba1891
@aminebenhebba1891 3 жыл бұрын
MediatR was "created" to make controllers a bit shortened by removing the data access code logic to one source of truth (MediatR) and segregate the commands and queries for a better maintainability in case of a lage projects and help to pin point the issues. we need to look at it like the old phone operator (you give him a command and he will take the charge of doing the work) its amazing how you can find programming solution looking to real world. im loving it and loving what is Mr.Corey doing for the C# community, your vedios are priceless sir. will be very interessting to apply this patern to your TimcoRetailManager series on your controllers, it will be a very good show case. thx a lot.
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 3 жыл бұрын
Thank you Amine for watching and sharing those thoughts
@tomasztyszka3985
@tomasztyszka3985 4 ай бұрын
Most helpful, thank you!
@IAmTimCorey
@IAmTimCorey 4 ай бұрын
You are welcome.
@VuvaToniKroos
@VuvaToniKroos Жыл бұрын
Thank you, Tim Corey
@IAmTimCorey
@IAmTimCorey Жыл бұрын
You are welcome.
Intro to Redis in C# - Caching Made Easy
1:27:29
IAmTimCorey
Рет қаралды 176 М.
CQRS pitfalls and patterns - Udi Dahan - NDC Oslo 2023
59:26
NDC Conferences
Рет қаралды 24 М.
Magic trick 🪄😁
00:13
Andrey Grechka
Рет қаралды 54 МЛН
When you discover a family secret
00:59
im_siowei
Рет қаралды 15 МЛН
WHO CAN RUN FASTER?
00:23
Zhong
Рет қаралды 46 МЛН
Happy birthday to you by Tsuriki Show
00:12
Tsuriki Show
Рет қаралды 12 МЛН
Intro to Records in C# 9 - How To Use Records And When To Use Them
1:19:44
.NET 7  💥  - Intro to CQRS and MediatR with ASP.NET Core Web Api
1:06:48
CQRS & MediatR in a .NET 8 Web API 🚀
22:00
Patrick God
Рет қаралды 8 М.
"The Life & Death of htmx" by Alexander Petros at Big Sky Dev Con 2024
23:01
Montana Programmers
Рет қаралды 54 М.
Don't Use Polly in .NET Directly. Use this instead!
14:58
Nick Chapsas
Рет қаралды 58 М.
.NET Framework vs .NET Core vs .NET vs .NET Standard vs C#
25:14
IAmTimCorey
Рет қаралды 550 М.
Intro to Azure Service Bus - The Power Behind Microservices
1:16:37
IAmTimCorey
Рет қаралды 136 М.
Clean Architecture with ASP.NET Core with Steve "Ardalis" Smith (2020-06-01)
1:50:17
10 C# Libraries To Save You Time And Energy
33:59
IAmTimCorey
Рет қаралды 206 М.
Magic trick 🪄😁
00:13
Andrey Grechka
Рет қаралды 54 МЛН