Programming

SQL Stored Procedure in .NET Core

SQL stored procedure in .NET Core. I call SQL stored procedures slightly differently in .NET Core to the way I did in .NET framework as I now pass the connection string through as an argument and I need to remember to add the System.Data.SqlClient NuGet package. public static List<string> GetBlogSummaries(string Read more…

Programming

SqlDataReader Null Handling

SqlDataReader null handling When reading values from a SqlDataReader in .NET null SQL values will cause the reader to error. I used to have an explicit null check around each column, however as this involved quite a bit of code duplication I had a look for something better and found Read more…

Programming

SQL Stored Procedure In .NET

I generally end up forgetting how to return results from a SQL stored procedure within .NET so I figured I’d put it here for reference. public static List<Blog> GetBlogSummaries() { List<Blog> blogs = new List<Blog>(); using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings[“BlogDatabase”].ConnectionString)) { using (SqlCommand command = new SqlCommand(“sp__get_blog_summaries”)) { command.CommandType Read more…