Programming
Select List Enum Tag Helper
If you want to have a select list in a web page which is based on all the values in an enum then you can use the built in function “Html.GetEnumSelectList” with a tag helper.
If you want to have a select list in a web page which is based on all the values in an enum then you can use the built in function “Html.GetEnumSelectList” with a tag helper.
In addition to the SingleOrArrayEnumConverter 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. This can then be used to decorate your enum class like so.
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.
I use the WinSCP dll to download files from SFTP sites in SSDT, as shown here, but this approach doesn’t work in .NET Core applications as the WinSCP dll isn’t available as a NuGet package. An alternative to WinSCP is SSH.NET, which amoung other things, has the ability to download Read more…
I often need to download files from an SFTP site in SQL Server Data Tools (SSDT), the best way I’ve found of doing this is a script task that hooks into WinSCP. WinSCP and it’s dlls can be downloaded here. Once installed, the dll should also be added to the Read more…
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…