ASP NET Core dependency injection tutorial

  Рет қаралды 423,898

kudvenkat

kudvenkat

Күн бұрын

Пікірлер: 165
@bolafahmi
@bolafahmi 4 жыл бұрын
Dependency Injection was a mystery for me before this video, and I simply did not know why bother with all the additional code. Thanks man A LOT.
@brudog56
@brudog56 2 жыл бұрын
Same here! This is the simplest, most concise explanation of DI I’ve come across. I’ve just been assuming DI worked over PFM (as in “Pure F***in’ Magic”) LOL
@yasirhabibkhugiani
@yasirhabibkhugiani 4 жыл бұрын
I wish all who teaches technical concepts in universities were like you, it would have been so easier. You have amazing ways to deliver a hard concept in a very easy understandable way.
@bogdan.p
@bogdan.p 5 жыл бұрын
Well, after reading docs from Microsoft and asking .NET Developers about how DI works and why I need it I finally understand with your tutorial. Thank you very much for your work!
@abhishekbajpai9920
@abhishekbajpai9920 4 жыл бұрын
Finally!!! I've understood what Dependency Injection is. Thank you so much, man!!!
@ramzirich2585
@ramzirich2585 Жыл бұрын
I failed my interview because of why we use interface , the interviewer wanted to go so in depth with this question in this video and the previous one I understood why we use interface and and DI thank you very much I searched a lot for this topic but you offer the easiest explanation Thank you from the bottom of my heart
@tetley3737
@tetley3737 3 жыл бұрын
Right to the point, no wasted time bloating the video, just a very clear explanation of DI. Thanks.
@saidrahman5948
@saidrahman5948 5 жыл бұрын
Simply I wanna say----> I just like it. Thanks a lot...........
@dimasjimenez3396
@dimasjimenez3396 5 жыл бұрын
You sir are the goat. The best tutorials no matter the technology. THANK YOU!
@alex_g
@alex_g 5 жыл бұрын
Goat? do you know what 'goat' means?
@saivaibhavmedavarapu7383
@saivaibhavmedavarapu7383 5 жыл бұрын
@@alex_g lol
@sherifezzat4983
@sherifezzat4983 5 жыл бұрын
@@alex_g Great Of All Time!! and Yup he is! Thanks so much Sir.
@kunsssssss113
@kunsssssss113 4 жыл бұрын
This is the best dot net core tutorial series in the internet
@hollowbyakuya2924
@hollowbyakuya2924 7 ай бұрын
even though these videos are old the concepts havent changed. absolutely top quality stuff
@adamameen5
@adamameen5 2 жыл бұрын
What a brilliant video.. Great stuff. I judged the video by the thumbnail, and thought it wouldn't be great, but what a great explanation.. 🔥❤ "Never judge a book by it's cover"
@khalidkachachi6595
@khalidkachachi6595 3 жыл бұрын
A Very Very good explanation of Dependency Injection in ASP.NET Core, Thnaks man.
@IamSandeepKmr
@IamSandeepKmr 5 жыл бұрын
You are dong a great service to developer community. Your work is admired by everyone across the world. What a presentation! What a control!
@carlosinigo9225
@carlosinigo9225 4 жыл бұрын
I really like your explanation of the logic behind the use of AddSingleton instead of tightly coupling the implementation of IEmployeeRepository. Thank you for the great work! Absolute best!
@NikhilShirgaonkar
@NikhilShirgaonkar 4 жыл бұрын
Why in the world can't people explain this simple like Venkat does I use to really wonder why for god shake why we need interface when things can be done straight forward UR GOD of programming bro just wonderful
@YahyaKawia
@YahyaKawia Жыл бұрын
Thanks for the explanation on instructor injection. It has helped my understanding of the dependency injection concept.
@mamadoudiallo8988
@mamadoudiallo8988 2 жыл бұрын
Thanks Kudventkat for your time to sharing this helpful tuto, keep it up i appreciate it a lot
@sam0070070071981
@sam0070070071981 2 жыл бұрын
Great explanation.. Nobody explains like you . Hats off to you.
@MrRAHUL7777777
@MrRAHUL7777777 Жыл бұрын
Your teaching method is very impressive and doubt clearing
@nirmalasundar2666
@nirmalasundar2666 4 жыл бұрын
Best video that I have ever seen🙏 Thanks for all your help🙏❤️
@manjinderbajwa1468
@manjinderbajwa1468 5 жыл бұрын
Venkat you are a genius when you explain the concepts ..to the point ...thanks dear
@DecentProgrammer
@DecentProgrammer 3 жыл бұрын
Finally!!! I have understood what DI is. Thanks Sir.
@Csharp-video-tutorialsBlogspot
@Csharp-video-tutorialsBlogspot 3 жыл бұрын
You are very welcome and thank you very much for taking the time to provide feedback.
@jaheershashaik5270
@jaheershashaik5270 3 жыл бұрын
Wow, Simply Wow
@rongliao9255
@rongliao9255 4 жыл бұрын
Great tutorial! Clear and concise explanation!
@Csharp-video-tutorialsBlogspot
@Csharp-video-tutorialsBlogspot 4 жыл бұрын
Hello Rong - Thank you very much for the feedback. Means a lot. I have included all the .NET core tutorial videos, slides and text articles in sequence on the following page. Hope you will find it handy. www.pragimtech.com/courses/asp-net-core-mvc-tutorial-for-beginners/ When you have some time, can you please leave your rating and valuable feedback on the REVIEWS tab. It really helps us. Thank you. Good luck and all the very best with everything you are doing.
@amine-ps2ib
@amine-ps2ib 4 жыл бұрын
the best tutorial with the best explanation. thank you
@missjude01
@missjude01 4 жыл бұрын
very well explained, thank you!
@interviewhappy
@interviewhappy 2 жыл бұрын
Ultimate explanation
@afzalbazeer600
@afzalbazeer600 2 жыл бұрын
The best. Ur explanations are awesome sir.
@IMateme
@IMateme 5 жыл бұрын
great great great, and simple , thank you very much
@ArifShaikh-dt3fy
@ArifShaikh-dt3fy 4 жыл бұрын
One word 'WOW'. Very well explained.
@PremKumar-kg5ep
@PremKumar-kg5ep 2 жыл бұрын
Your videos is so great..
@progalion4647
@progalion4647 3 жыл бұрын
WOW , Thank you so much , very useful video
@nikhilkolhe2064
@nikhilkolhe2064 3 жыл бұрын
First time I understood dependency injection🙏🙏
@gregoryhoward7594
@gregoryhoward7594 4 жыл бұрын
GREAT VIDEO!!! I like how you gave a real world example of why this matters rather than assume everyone knows this. It would be so much better if other people would do this with their videos OR explanations on information websites. I will continue to see if you covered the other ways of Dependency Injection. This is good stuff.
@antoniocolombo9414
@antoniocolombo9414 2 жыл бұрын
Thanks! That's exacly what I was looking for
@mohdilyas7962
@mohdilyas7962 4 жыл бұрын
Very great explanation, I want such tutorials taking less time to understand as it focuses on the main topic, thanks
@waelmrabet6841
@waelmrabet6841 4 жыл бұрын
Great tutorial bro thx !!
@anvineet
@anvineet 4 жыл бұрын
Thanks so much for explaining lot about DI. Its so simple and so deep to understand.
@mrohailiqbal
@mrohailiqbal 4 жыл бұрын
Very nicely explained. Thanks a lot Sir.
@michaelwassell5287
@michaelwassell5287 3 жыл бұрын
Great video, just what I need for my university project.
@Csharp-video-tutorialsBlogspot
@Csharp-video-tutorialsBlogspot 3 жыл бұрын
Thank you Michael. Means a lot. If you are planning to become a full stack software engineer, I think the following video will be of some help. kzbin.info/www/bejne/iJqulIZ6l6yJjtk
@anselhobs6111
@anselhobs6111 3 жыл бұрын
Nice
@santosharakere
@santosharakere 5 жыл бұрын
Excellent demo of DI, great job. Thanks Venkat.
@Vykhari1
@Vykhari1 3 жыл бұрын
Thank you very much Venkat. Your videos are really helpful.
@eduAIJourney
@eduAIJourney 3 жыл бұрын
Thank you so much what a excellent explanation
@EriAirlangga
@EriAirlangga 5 жыл бұрын
Martin Fowler is a genius living legend. All patterns we know of nowadays stem from his brain
@jatinkumar4410
@jatinkumar4410 2 жыл бұрын
Amazing explanation. Thanks
@fahim8690
@fahim8690 9 ай бұрын
❤❤Great Video Sir
@Fkn1405
@Fkn1405 4 жыл бұрын
Almost hit the like button TWICE!!!
@shaimaasayed6971
@shaimaasayed6971 Жыл бұрын
Thank you so much really helpful
@navyanarayanarao8694
@navyanarayanarao8694 4 жыл бұрын
Amazing Amazin Amaaaazing!!
@ashokrajur09
@ashokrajur09 3 жыл бұрын
short and to the point, thanks
@daredevilpantera
@daredevilpantera 3 жыл бұрын
Fantastic Video Gentleman
@junaid_aslam
@junaid_aslam 3 жыл бұрын
What an amazing explanation. Kudos!
@thetechlancer
@thetechlancer 8 күн бұрын
so to the point ❤
@abdulkadir-lk4xg
@abdulkadir-lk4xg 3 жыл бұрын
Great
@naodagere8210
@naodagere8210 4 жыл бұрын
Ur best! marvelous!!!
@dhliu9687
@dhliu9687 Жыл бұрын
Thanks teacher venkat, check in today !
@VikramSingh-kk1mg
@VikramSingh-kk1mg 4 жыл бұрын
amazingly explained
@gaurravprakash
@gaurravprakash 5 жыл бұрын
My question is regarding services.AddSingleton(). How can I add multiple concrete implementations of IEmployeeRepository, and then be able to use one of them at run time depending upon the situation?
@jmurrayhead
@jmurrayhead 4 жыл бұрын
Look into the Factory pattern.
@Rafian1924
@Rafian1924 9 ай бұрын
Genius ❤
@richardflores8542
@richardflores8542 5 жыл бұрын
Thank you! Great video.
@JoseAlvarez-dl3hm
@JoseAlvarez-dl3hm 4 жыл бұрын
It was really well explained. Although I did not get the difference between singleton, scoped and transient, and when to use one over the others.
@SelmanErhanekici
@SelmanErhanekici 5 жыл бұрын
You're doing great job.
@SilverMan93
@SilverMan93 5 жыл бұрын
You make it so easy to understand, thank you sir
@kelumedirisinghe1735
@kelumedirisinghe1735 3 жыл бұрын
well explained!
@aaronaaronaaron5922
@aaronaaronaaron5922 5 жыл бұрын
I like this enjoyable videos a lot!!
@hadisandid4671
@hadisandid4671 4 жыл бұрын
Great explanation, thank you
@leonvanrijswijk8409
@leonvanrijswijk8409 5 жыл бұрын
I really love your videos, but not this one. For me it was very confusing. Maybe a slide with a diagram of dependencies would have helped to make it clearer
@karimkazia
@karimkazia 5 жыл бұрын
Awesome Thank you!!
@davidfong7624
@davidfong7624 3 жыл бұрын
Subscribed!
@AAFactor
@AAFactor 5 жыл бұрын
Awesome bro ... just awesome :)
@nisarahmad3370
@nisarahmad3370 5 жыл бұрын
Dear sir, kindly make a tutorial for generic repository and unit of work. We are badly missing it. Thanks
@trustingod0
@trustingod0 3 жыл бұрын
If you search around there are many more thorough tutorials available. If you notice his videos are short and "Sweet". There are many instructor led tutorials that do a far better job than Kudvenkat. He may be good at teaching things via his steps approach which shows you what to do in theory but you might be missing the bigger picture in the application of dependency injection via SOA.
@ozimax06
@ozimax06 5 жыл бұрын
what is the point of using Interface for Repositories and creating mock objects while you can create an in-memory database of DB context and passing directly to classes for unit testing? That's one of the features of .NET core
@honeytrippers
@honeytrippers 5 жыл бұрын
The "Previous" and "Next" video links are wrong pointing to video 17 and 18 ...and a bit quick for a complex concept
@sumersinghrana8868
@sumersinghrana8868 5 жыл бұрын
Nice explain.
@haziqt
@haziqt 4 жыл бұрын
Love it
@ayedabboushi7221
@ayedabboushi7221 5 жыл бұрын
very cleared, thank you venkat
@manishakharade6198
@manishakharade6198 4 жыл бұрын
Thanks a lot...
@RaviBedre90
@RaviBedre90 4 жыл бұрын
Nice tutorial.....Is there any other way to register the service except to use the extension method????
@Krranganathakr
@Krranganathakr 4 жыл бұрын
Hi Sir , one question here , As i have just one implementation here , but in reality i may implement 2 class with same interface utilization , now if i mentioned in start up file service.addsingleton and service.addsingleton, in this case what will happen . Please suggest .Thanks for your all videos , I really enjoying while learning with your videos .
@ianmohlie
@ianmohlie 4 жыл бұрын
Great video, thanks. I might be confused about the different methods of DI (eg what you did here vs using Autofac). Question: Do you always have to register your interfaces in Startup? I watched another video where he didn't have to use Startup to tell Visual Studio which implementing class to use - he simply passed that class as an input when calling the method ("C# Dependency Injection Constructor" by Theenk, specifically 14:09-14:40). Can you please explain to me the difference in your two approaches? Also: - are "interfaces" synonymous with "services"? (see your video at 3:15) - is "registering" the same as "binding"?
@pavankogpayana
@pavankogpayana 5 жыл бұрын
you make it so easy to understand concepts,why so fast sir?
@DecentProgrammer
@DecentProgrammer 3 жыл бұрын
Thank sir
@somnathsharma9979
@somnathsharma9979 3 жыл бұрын
But in what scenario where we need to change mockrepository class to sqlrepository class implementation as you mentioned in video
@bhadrik
@bhadrik 3 жыл бұрын
👍👍👍👍👍👍
@patelabhay1267
@patelabhay1267 3 жыл бұрын
Can you please add a video which shows Multiple implementations for Dependency Injection like in the current video (Part 19) you show one implementation for MockEmployeeRepository, how to manage if in future we have other implementation for IEmployeeRepository?
@microtech2448
@microtech2448 5 жыл бұрын
Nice, much clearer now. One question though, can you please tell us if this is possible to register multiple implementations of same interface using DI and selectively use one at constructor level or method or property level as required.
@amineherizi4687
@amineherizi4687 5 жыл бұрын
No you can't must have for each interface one implementation otherwise the DI engine can't decide which one to use
@microtech2448
@microtech2448 5 жыл бұрын
@@amineherizi4687 How would you inject dependencies in tutorial example, IEmployee, PermanentEmployee, ContractEmployee
@microtech2448
@microtech2448 5 жыл бұрын
@venkat, can you please explain how to inject multiple implementations of same interface otherwise if it is not possible doing so then what is use of interfaces and multiple classes inheriting same interface
@sandeepbrk
@sandeepbrk 5 жыл бұрын
You can use IEnumerable collection and linq for that. Inbuilt dependency injection is not supporting multiple classes from single interface. Below is the code sample. Services : public interface ITest { void writeMsg(string t); } class ATest : ITest { public void writeMsg(string t) { Console.WriteLine(t + "A"); } } class BTest : ITest { public void writeMsg(string t) { Console.WriteLine(t + "B"); } } Getting particular service through controller injection : ITest _itest; private readonly IEnumerable _itests; public HomeController(IEnumerable itestList) { _itests = itestList; _itest = _itests.First(o => o.GetType() == typeof(BTest)); } Here you can get the instance of BTest class. Hope this helps.
@sergiocorrenti
@sergiocorrenti 5 жыл бұрын
thank you idol
@MsAlexandr76
@MsAlexandr76 Жыл бұрын
Part 44 (from 8:33) of this Tutorial discussed about these 3 methods in details
@tamaradmoni1611
@tamaradmoni1611 5 жыл бұрын
Thank you for this great tutorial! Is there a place we can ask questions about the tutorial?
@Csharp-video-tutorialsBlogspot
@Csharp-video-tutorialsBlogspot 5 жыл бұрын
Hello Tamar - Please ask your question on the respective video as a comment. Hope this helps.
@ultrahyena3013
@ultrahyena3013 5 жыл бұрын
@@Csharp-video-tutorialsBlogspot I'm wondering if what he really means is, have you ever thought about actually answering people's questions?
@Leon-kd2ih
@Leon-kd2ih Жыл бұрын
can someone please explain to me how would I create an instance of HomeController? As I understand the DI Container will handle the dependency injection.
@trustingod0
@trustingod0 3 жыл бұрын
Can I use a repository pattern with .Net Core Entity framework so that I can switch out implementations? For example lets say I want to use a class like MockEmployeeRepository for testing but I also want the flexibility to use a SQL Server data store. Thanks !!!
@meeramaahidoshi1207
@meeramaahidoshi1207 3 жыл бұрын
i am not getting the output marry instead still getting hello world with version 3 above. what would be the problem?
@reyneermorales6123
@reyneermorales6123 3 жыл бұрын
What if I want to use a class library? a class library does not include the startup.cs class.
@ravivishwakarma7786
@ravivishwakarma7786 Жыл бұрын
How does the call parameterize the constructor 0.12
@richardprakash4630
@richardprakash4630 4 жыл бұрын
how to handle DI if there are multiple implementation of the interface and want to use both??
@AB-fs8jl
@AB-fs8jl 5 жыл бұрын
If you even see this: Getting an error on the line public HomeController(IEmployeeRepository employeeRepository) Error message: inconsistent accessibility: parameter type 'IEmployeeRepository' is less accessible than method 'HomeController.HomeController(IEmployeeRepository)'
@dejanradojevic3297
@dejanradojevic3297 5 жыл бұрын
You need add public access modifier in front of interface IEmployeeRepository.
@harishsalapu8968
@harishsalapu8968 4 жыл бұрын
Even after adding public access modifier we r facing that error. Kindly help if anyone knows
@phanidivi3613
@phanidivi3613 5 жыл бұрын
Simply supb venkat sirrrrrr......
@ymtan
@ymtan 5 жыл бұрын
I am not able to understand the concept of ASP.NET Core Dependency Injection. Could you kindly please explain the following code block because I don't understand the code ? public class HomeController : Controller { private IEmployeeRepository _employeeRepository; public HomeController(IEmployeeRepository employeeRepository) { _employeeRepository = employeeRepository; } public string Index() { return _employeeRepository.GetEmployee(1).Name; } }
@phanidivi3613
@phanidivi3613 5 жыл бұрын
@@ymtan Creating a object of dependent class with out using new keyword called Dependency injection.In our code accessing a concurrent class is MockEmployeeRepository (dependent class) in HomeController class need to create object. Whenever we are creating the object using new keyword,both the class are tightly coupled.So main concept of DP is loosely coupled.The solution is to pass dependent class or interface instance variable as a parameter to a home controller constructor.
@phanidivi3613
@phanidivi3613 5 жыл бұрын
In this video venkat sir explain very clearly,by changing the depend class constructor,immediately home controller getting an error.So by passing dependent class or interface instance,the error was gone.
@phanidivi3613
@phanidivi3613 5 жыл бұрын
I have understand this only.Please correct if am wrong.
@phanidivi3613
@phanidivi3613 5 жыл бұрын
@@ymtan Previously,we are using third party tools like unity.mvc5 to providing and resolve the errors in DP .
@klearner666
@klearner666 Жыл бұрын
What if don't inject and when we need to change MockEmpRep() to SqlEmpRep() type we just changed the code inside the mock and as a result only one place needed to changed.? Please someone clarify me this.
@1Eagler
@1Eagler 2 жыл бұрын
Great playlist - too bad it;s for V2.2
@TheSree9120
@TheSree9120 5 жыл бұрын
one doubt sir, If two classes implementing the same interface and having the same method, then if i call the method with that interface, which class method will be called?
@Kobriks1
@Kobriks1 5 жыл бұрын
The one which is registered in ConfigureServices. If you try to register both you will get an error.
@sandeepbrk
@sandeepbrk 5 жыл бұрын
You can use IEnumerable collection and linq for that. Inbuilt dependency injection is not supporting multiple classes from single interface. Below is the code sample. Services : public interface ITest { void writeMsg(string t); } class ATest : ITest { public void writeMsg(string t) { Console.WriteLine(t + "A"); } } class BTest : ITest { public void writeMsg(string t) { Console.WriteLine(t + "B"); } } Getting particular service through controller injection : ITest _itest; private readonly IEnumerable _itests; public HomeController(IEnumerable itestList) { _itests = itestList; _itest = _itests.First(o => o.GetType() == typeof(BTest)); } Here you can get the instance of BTest class. Hope this helps.
@anuyajoshi4360
@anuyajoshi4360 4 жыл бұрын
Thank you for questions and shared relevant answers. They all help to improve.
Controller in ASP NET Core MVC
8:51
kudvenkat
Рет қаралды 198 М.
AddSingleton vs AddScoped vs AddTransient
15:23
kudvenkat
Рет қаралды 213 М.
Running With Bigger And Bigger Lunchlys
00:18
MrBeast
Рет қаралды 120 МЛН
Как подписать? 😂 #shorts
00:10
Денис Кукояка
Рет қаралды 8 МЛН
Bike Vs Tricycle Fast Challenge
00:43
Russo
Рет қаралды 105 МЛН
Setup mvc in asp net core
10:26
kudvenkat
Рет қаралды 210 М.
Dependency Injection in .NET Core (.NET 6)
1:00:32
IAmTimCorey
Рет қаралды 191 М.
Dependency Injection for ASP NET Core 6.0 - An UPDATED 2022 Tutorial
8:10
Dependency Injection, The Best Pattern
13:16
CodeAesthetic
Рет қаралды 831 М.
ASP NET Core appsettings json file
11:33
kudvenkat
Рет қаралды 337 М.
Dependency Injection Deep Dive | .NET & C# Essentials
38:01
Amichai Mantinband
Рет қаралды 23 М.
😱ЭТО СМАРТФОНЫ SAMSUNG!
1:00
Thebox - о технике и гаджетах
Рет қаралды 2,2 МЛН
Самый дорогой iPHONE 16 PRO MAX #shorts
0:58
Арсений Петров
Рет қаралды 2,4 МЛН
Самые крутые школьные гаджеты
0:46