3 ms·
Is there any example of how this would work with dependency injection? Or it's expected to manually call the service provider inside the lambda? Or if I just a
by 0xcoffee 5y ago
Is there any example of how this would work with dependency injection? Or it's expected to manually call the service provider inside the lambda?
Or if I just add my interfaces to the lambda parameters they will automatically resolved?
edit: It supports DI using `[FromServices]` attribute!
https://gist.github.com/davidfowl/ff1addd02d239d2d26f4648a06158727?WT.mc_id=-blog-scottha#explicit-parameter-binding https://gist.github.com/davidfowl/ff1addd02d239d2d26f4648a06...
edit: Apparently this was in the article, but I overlooked it..
- Vake93 5y agoJust pass them as parameters for the lambda. Good Example: https://github.com/DamianEdwards/MinimalApiPlayground/blob/main/src/Todo.Dapper/Program.cs#L33 https://github.com/DamianEdwards/MinimalApiPlayground/blob/m...
- zzbzq 5y agoThe target audience for it, though, is probably us folks who want to remove dependency injection altogether. It was going against the grain before because the whole framework was built around Controllers and the part of the pipeline that had a monopoly on constructing them. With these changes it looks like it will be fully supported to write server-side HTTP code as if it were a computer program. Like you can in any other language. Better late than never!
- tonyedgecombe 5y agoThat's interesting, I've been avoiding .Net for web projects because of the DI. Time to take another look.