Single or Array Enum JSON Converter
In addition to the SingleOrArrayConverter mentioned previously I’ve also created a version to translate enums to/from JSON using the name of the enum rather than it’s value as is the default.
In addition to the SingleOrArrayConverter mentioned previously I’ve also created a version to translate enums to/from JSON using the name of the enum rather than it’s value as is the default.
Often APIs will have actions where one of the parameters can be either a single object or an array of objects, in order to correctly serialize objects to JSON which can be accepted by the API a custom JsonConverter is needed. This code is borrowed from this stack overflow article. Read more…
I have a list of EventType objects with the following definition. These are used in a web application where the properties can be adjusted and the resulting list is posted back to the controller action. Rather than updating all the objects returned (even the non-modified ones) I wanted to extract Read more…
I’ve been using Switchery in various sites to make nice looking checkboxes, however whilst browsing the projects GitHub issues I spotted one post that said it was possible to replicate it’s functionality using pure CSS (though possibly at the cost of browser compatibility). This seems to work pretty nicely and Read more…
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 this Stack Overflow Read more…
I recently migrated this blog over to WordPress from BlogEngine.NET as BlogEngine.NET seems to have been abandoned. In the process of setting up WordPress I discovered that the backend database is MySQL, as I mostly work with Microsoft SQL Server and a SQL database on Azure is cheaper than than Read more…
The script tasks in SSIS can be a bit limited in what they allow you to do as NuGet packages can’t be used and not all class libraries seem to be available. Given that, below is my code for calling an external API and logging it’s results to a SQL Read more…
While trying to convert some integers to hex values in SQL I found a few options that worked on ints and bigints but nothing that worked on anything larger and as I was needing to convert some integers of datatype decimal(20) I created the below function which is based on Read more…
Adding logging to a .NET Core console application In .NET Core projects logging is managed via dependency injection. Whilst this works fine for ASP.NET projects where this is all automatically created upon starting a new project in Startup.cs, in console applications it takes a bit of configuration to get it up and Read more…
UPDATE: It appears that there’s now a “Worker Service” template available (thanks Hobby Developer) which scaffolds Dependency Injection, configuration and logging for you. If you wnat a long running service then that’s probably the best option but if you want an intermitantly triggered executable that does a defined task and Read more…