Тёмный

Using Unit of Work Pattern 

Study Mash
Подписаться 13 тыс.
Просмотров 35 тыс.
50% 1

Unit of work and repository pattern goes hand in hand. We use Unit of Work to perform various CRUD operations on multiple repositories as a single Unit of Work. Means either all of operations should be successful in a transaction or nothing should be committed to the persistence storage. It will help to avoid database inconsistency.
Next we will understand what is Data Transform Objects (DTO) and how those are important to protect our API from various security vulnerability.
Code of up to this point is available on below GIT repository
github.com/webtrainer-in/HSPA... .
You can support me by donating on
www.buymeacoffee.com/studymash
Thanks
Studymash

Опубликовано:

 

16 окт 2020

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 45   
@PrinceKumar-eb8hd
@PrinceKumar-eb8hd 3 года назад
I don't have words to say, even a person will spend lakhs of rupees but won't get this much of understanding, I watched all video of this series more than 3 times & will watch more no of times, Really by watching again & again video, I understand the concept very well. Thank You so much @study Mash..lots of Respect for you!
@StudyMash
@StudyMash 3 года назад
Thanks Prince, hope you are doing well in your new job.
@javierfelixalonsolopez3946
@javierfelixalonsolopez3946 3 года назад
Best way to explain it. THANKS! you help me understand the last part with the BEGIN TRAN and COMMIT TRAN analogy!! Excellent work! Im subscribing!
@codeschool3964
@codeschool3964 Год назад
I watching lot of videos and trying to understand UOW. This is the shortest and the best one. Now I understand what uow is. Thanks a lot. Keep up!
@StudyMash
@StudyMash Год назад
Glad to hear that buddy
@flywheel56
@flywheel56 3 года назад
Enlightening tutorial on an elegant pattern.
@Apprenticer
@Apprenticer 2 года назад
After 1 minute of watching the video I added you to my favs. Subscribed. I really like your way of explaining things. and topics you teach!!! I wish your examples were in java and jpa.
@harrylyod3402
@harrylyod3402 3 года назад
Thank you for the new video been waiting for a while.
@nileshprajapati119
@nileshprajapati119 3 года назад
Nice and easy to understand content for beginner !!
@sandeepreddy475
@sandeepreddy475 2 года назад
After a lot of research, Finally here is someone who can throw away my confusion. Thank you man..!
@StudyMash
@StudyMash 2 года назад
Glad to hear that Sandeep
@samerelsahih
@samerelsahih 2 года назад
Wish I could like your videos multiple times over :) I've been a developer for a decade and still learn a lot from your videos.
@StudyMash
@StudyMash 2 года назад
Glad to hear that Sam
@matthayden1979
@matthayden1979 Год назад
I couldn't agree with you more!
@gajendrasalunkhe5750
@gajendrasalunkhe5750 3 года назад
Thanks a lot. Very well explained. Saved my day.
@NickEnchev
@NickEnchev 3 года назад
Excellent video, thanks!
@nelsonthekinger
@nelsonthekinger 2 года назад
Beautiful Engineering 👌 Well done
@techrelated2417
@techrelated2417 3 года назад
awsome explaination!! Thanks
@tmmuttathara
@tmmuttathara 3 года назад
very explanative. understood many things i left out.
@avinashg2008
@avinashg2008 3 года назад
wat a video. amazing. thanks one query: does it mean that if we are using EF core then there is no need to implement uow, repository patterns explicitly?
@joeycopperson
@joeycopperson 2 года назад
Thanks. Very good explanation :)
@nagendrakumar4983
@nagendrakumar4983 3 года назад
It was pretty clear. Thanks
@rohitpawar8710
@rohitpawar8710 3 года назад
nice explaination
@cmnckang8291
@cmnckang8291 2 года назад
this is amazing
@nasmob5656
@nasmob5656 2 года назад
Legend !
@nelsonthekinger
@nelsonthekinger 2 года назад
Should a Unit of work have all the repositories? Or should only have the repositories used on the endpoint? Or should only have one repository ? (doesn't seem to make sense)
@DaveRoman-mc4nn
@DaveRoman-mc4nn 2 года назад
Should not have all repositories. Use a generic repository and add it as a property in the IUnitOfWork interface.
@goodoleme747
@goodoleme747 2 года назад
Why didn’t you inject CityRepository into your UnitOfWork class? I don’t think newing up the repository is a good idea because that also violates dependency inversion.
@mi5956
@mi5956 3 года назад
what if we have store procedures, do we still need UOW?, because most of SPs are complete script for saving changes and everything we just need to call it.
@ahmadbaderkhan598
@ahmadbaderkhan598 2 года назад
no you don't need it . don't write more code if you don't need to . these patterns solve a problem basically . what you're describing is a non problem since stored procedures you can do multiple stuff at once . so i would just have the repo calling it
@khaledsaleh7798
@khaledsaleh7798 2 года назад
what about TransactionScope() ? is it an alternative to unit of work?
@adamschneider868
@adamschneider868 Год назад
Thats ACID and just ensures that you dont store incomplete data in the database.
@sajad5644
@sajad5644 3 года назад
hi , i have some sort of question , putting all repositories in a single uow class is normal way ? or we should create multiple uow depend amount of relationship between repositories ?
@StudyMash
@StudyMash 3 года назад
Splitting UOW is developer's own choice, but we should always make sure to put all relational repo in single UOW, others you will end up facing transactions issue while saving the data of relational entities.
@sajad5644
@sajad5644 3 года назад
​@@StudyMash thank you alot, In such a way application will be slower , isn't it ? for example we have more than 10 or 20 repositories and so for a single request we are creating instance of 10(or 20) repository but we are using just two of them, yes every things have pros and cons ,but how much it can reduce speed
@StudyMash
@StudyMash 3 года назад
@@sajad5644 If you look at the UnitOfWork.cs file, you can see different repositories are accessible using properties, I have not initialized it in constructor. So the answer to your question is : No it will not be slower, because it will not create an instance of repository until you will use that somewhere in controller.
@sajad5644
@sajad5644 3 года назад
@@StudyMash I realized ,tanx so much, please if you can ,in one of your future videos teach us how we should use usermanager in such a way(uow) , because as i know usermanager save transaction automaticly (i know about userStore and how to pass dbcontext instance to it but we(me and i think other guies) are not familiar with uow when using usermanager , It can be very helpful if u do that(for example what is required for creating instance of usermanager and so on..) tanx tanx tanx
@DaveRoman-mc4nn
@DaveRoman-mc4nn 2 года назад
@@StudyMash That's a good approach, but even for each property, you're reserving memory for each repository attribute (this makes the UnitOfWork instance heavy). That's a waste of memory if you only want to use two repositories in one request.
@eswar338
@eswar338 3 года назад
Can you use a generic repository instead of using multiple Repositories
@StudyMash
@StudyMash 3 года назад
Yes I will use generic one for the basic functionality in upcoming lessons
@eswar338
@eswar338 3 года назад
@@StudyMash Thanks. I am expecting CRUD operations using generic Reposit with UOW
@mahmoodamer2156
@mahmoodamer2156 2 года назад
can you give us a simple practical example sir
@rishikashnia1242
@rishikashnia1242 3 года назад
Wrong implementation. You breached the "D" of SOLID pattern by initializing the repository manually inside UnitOfWork. How would you MOCK the UOW in tests as it depends on concrete implementation of repository, Shouldn't it depends on abstraction (i.e. interface of repository) and dependency (repository) should be injected at run time.
@StudyMash
@StudyMash 3 года назад
Good question, I like it. No, its not wrong, we are already injecting UOW at runtime in controller and your are free to create your own concrete mock UOW and your own version of concrete repo because IUnitofWork is not depend on concrete type. So you can have own repo and uow that implement IUnitOfWork and IRepository. Feel free to let me know if you still have any question.
@sivasagarjagga6445
@sivasagarjagga6445 2 года назад
not clear and confusing..
Далее
Why to use DTO (Data Transfer Objects)
11:02
Просмотров 31 тыс.
Using Repository Pattern
14:10
Просмотров 10 тыс.
Hamster Kombat 20 July Mini Game
00:13
Просмотров 10 млн
ПОЮ НАРОДНЫЕ ПЕСНИ🪗
3:19:41
Просмотров 1,8 млн
The Unit of Work Design Pattern Explained
12:37
Просмотров 21 тыс.
Unit of Work Pattern in Unity
11:51
Просмотров 49 тыс.
Don't Use AutoMapper in C#! Do THIS Instead!
16:17
Просмотров 66 тыс.
Unit of Work in ASP.NET Core
14:57
Просмотров 18 тыс.
5 Rules For DTOs
17:56
Просмотров 39 тыс.
Deep Dive Into the Repository Design Pattern in Python
11:56
Using Automapper in C#
8:19
Просмотров 28 тыс.
Hamster Kombat 20 July Mini Game
00:13
Просмотров 10 млн