ASP.NET Core – Getting query string values

The ASP.NET Core framework automatically parses query strings (i.e. ?name=Dune&year=2021) into HttpContext.Request.Query and maps the query string values to action parameters (if you’ve added them). You can get the mapped query string values by adding action parameters, like this: Or you can use HttpContext.Request.Query directly (which is useful in many scenarios): This can either return … Read more

C# – Mapping nullable columns with SqlDataReader

When you have a database table with null columns, and you’re using SqlDataReader to map the results, there are a few things to do: Use nullable types in the model class. Example: instead of int use int? so the value can be null. Use SqlDataReader.IsDBNull() to check if you need to set the value to … Read more