4 ms·
Apart from needing two namespaces, this does look reasonable to me. I'm not sure how you could make constructor-based dependency injection easier without making
by fabian2k 6y ago
Apart from needing two namespaces, this does look reasonable to me. I'm not sure how you could make constructor-based dependency injection easier without making it less obvious what is happening. And most of the additional lines are stuff your editor can do for you, even in VS Code you can automatically generate the field and assignment and the imports after just typing the constructor parameter.
ASP.NET Core does push you strongly towards dependency injection, but it does not force you at all to use it.
- FridgeSeal 6y ago> ASP.NET Core does push you strongly towards dependency injection, but it does not force you at all to use it. Their own documentation for making queries against SQL Server doesn't provide examples of how to do it that aren't using DI. "Just inject it" it just says. Thanks .net, super helpful. Maybe the docs are there, but I couldn't find them at all when I went looking.
- mattmanser 6y agousing(var conn = new SqlConnection("<conn-string>")) using(var cmd = new SqlCommand(@"Query here", conn)) { conn.Open(); cmd.executeNonQuery(); }
- FridgeSeal 6y agoHmmmm, maybe I am just dense hahaha.