News for hackers. Stuff that matters.
Re:.NET 5.0 by fabian2k on Tuesday November 10, 2020 @12:50PM (#25048756)
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.

Re:.NET 5.0 by FridgeSeal on Tuesday November 10, 2020 @05:14PM (#25052764)
> 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.

Re:.NET 5.0 by mattmanser on Tuesday November 10, 2020 @07:35PM (#25054131)

    using(var conn = new SqlConnection("<conn-string>"))
    using(var cmd = new SqlCommand(@"Query here", conn))
    {
      conn.Open();
      cmd.executeNonQuery();
    }
Re:.NET 5.0 by FridgeSeal on Wednesday November 11, 2020 @12:26AM (#25055735)
Hmmmm, maybe I am just dense hahaha.