.NET 9 Changes The Way You're Using Dependency Injection with Blazor Forever 🔥

  Рет қаралды 6,919

Patrick God

Patrick God

Ай бұрын

🚀 Join the .NET Web Academy: learn.dotnetwebacademy.com
💖 Support me on Patreon for exclusive source code access: / _patrickgod
🐦 Let's get social on Twitter/X: / _patrickgod
🔗 Let's connect on LinkedIn: / patrickgod
🚀 Get the .NET 8 Web Dev Jump-Start Course for FREE: dotnet8.patrickgod.com

Пікірлер: 25
@xelit3
@xelit3 20 күн бұрын
that's really interesting, and it standardize dependency injection in Blazor comparing with the rest of .NET ecosystem.
@oliverharvey7561
@oliverharvey7561 28 күн бұрын
Don’t know why anyone would want to do this - @inject seems perfect to me.
@kw-gz9fe
@kw-gz9fe Ай бұрын
Thank you for the update
@mehmetyirtici5322
@mehmetyirtici5322 Ай бұрын
Hello Patrick. Thank yor for this video.
@bartlomiejuminski
@bartlomiejuminski Ай бұрын
You can also use constructor injection in the ".razor" file not only in ".razor.cs" file.
@CRBarchager
@CRBarchager Ай бұрын
This is great. Back to good old DI with naming that starts with _ for global variable for that class/page. The Pascal naming for variables always threw me of a bit.
@OeHomestead
@OeHomestead Ай бұрын
I kinda perfer using [Inject] as it makes the code a bit tidier. If one rely on a lot of services, the constructor args can get quite long and messy.
@zagoskintoto
@zagoskintoto Ай бұрын
Yesssss!
@SteamF-nf2ts
@SteamF-nf2ts Ай бұрын
Hey Patrick, is it worth to change my .net 6 api to use the identity resources on .net 8? Or isnt that difference that big?
@thesandboxgamingvideos
@thesandboxgamingvideos Ай бұрын
finally they thought about this.
@iyerpram
@iyerpram Ай бұрын
How can we mock a dependency which is injected through attribute. Since the class members would have to be protected or public for mocking it. Isn't that against OOP Principles?
@10Totti
@10Totti Ай бұрын
Same coder for request keyedservices ?
@renynzea
@renynzea Ай бұрын
Can you use the new class level constructor in c# to avoid having to create the constructor and private variable. E.g.: class Home (IMyService MyService)?
@Cornelis1983
@Cornelis1983 Ай бұрын
I would like to know this as well. Or else, this new, better way of DI would reintroduce a nasty side-effect I was glad we got rid of by using the primary constructors: the underscore
@nikolayrogchev9628
@nikolayrogchev9628 Ай бұрын
Finally :)
@SteamF-nf2ts
@SteamF-nf2ts Ай бұрын
Is it worth it to change my .net 6 API to use identity's resources on .net 8? Or this difference isnt that big?
@heda4341
@heda4341 Ай бұрын
Hi Patrick, first thank you. can you please explain why this approach is better than the [inject]-approach ?
@zagoskintoto
@zagoskintoto Ай бұрын
I wouldn't say better, but I'm not expert so maybe there's something I'm not seeing that can be done this way and not the previous one. What I can say is that it's a far more coherent way to do it as it resonates with how DI is done in every other type of .NET class that is not a razor component.
@adrianspikes6454
@adrianspikes6454 Ай бұрын
So what happened to the global injection file 🤨? Oh and that's probably my one complaint about Blazor, those darn mysterious red squigglys for no apparent reason 🤷🤣
@bloggrammer
@bloggrammer Ай бұрын
Does this resolved as scoped, transient or singleton service?
@jinparksoul
@jinparksoul Ай бұрын
Depends which way you registered it in the program.cs.
@bramburn
@bramburn Ай бұрын
would you recommend blazor or django for fast development?
@quanghungnguyen3018
@quanghungnguyen3018 Ай бұрын
No! If you want to build fast application, you should using php
@Heas_Heartfire
@Heas_Heartfire Ай бұрын
I actually find constructor inyection pretty unreadable so I don't think I'll start using it in blazor if they give me the choice.
@josefromspace
@josefromspace Ай бұрын
Property injection is harder to UnitTest since there is no compile time validation.
Await Async Tasks Are Getting Awesome in .NET 9!
9:24
Nick Chapsas
Рет қаралды 89 М.
MEU IRMÃO FICOU FAMOSO
00:52
Matheus Kriwat
Рет қаралды 39 МЛН
Blazor WebAssembly ASP.NET Core Hosted in .NET 8 🔥
15:37
Patrick God
Рет қаралды 16 М.
Software engineer interns on their first day be like...
2:21
Frying Pan
Рет қаралды 13 МЛН
It's the Fastest Way with Blazor, Really 🚀
9:50
Patrick God
Рет қаралды 7 М.
Brutally honest advice for new .NET Web Developers
7:19
Ed Andersen
Рет қаралды 68 М.
Await Async Might Change Completely in .NET 9
9:55
Nick Chapsas
Рет қаралды 88 М.
Is Blazor Better than React?
14:25
Gavin Lon
Рет қаралды 42 М.
The New .NET 9 HybridCache That You Must Upgrade To!
14:34
Nick Chapsas
Рет қаралды 46 М.
WHY did this C++ code FAIL?
38:10
The Cherno
Рет қаралды 189 М.
Don't Use Polly in .NET Directly. Use this instead!
14:58
Nick Chapsas
Рет қаралды 49 М.