Categories
Programming

Execute Raw SQL Scripts in Entity Framework Core

Most of the time, Entity Framework Core will just do the right thing. Every now and then, though, you’ll find that it’s doing something in a bit of a sticky way and you’ll want to take control. Usually it’s when you’re deleting a range on a table with cascading deletes. Here’s an example of the […]

Categories
Programming

Simple Conditional Updates to Entities in ASP.NET Core MVC

When you accept a view model in your .NET Core MVC application, you can request that only certain fields are bound, like this [Bind(“Title”)]. Neat. But when you want to apply the changes to your domain object, you often want to do a similar thing and only update certain fields (and only if they really […]

Categories
Automation Programming

Remove Blank Lines From a File with PowerShell

When importing a file full of data into a test system, I discovered that the CSV library I was using to do all the work was stopping when it reached a blank line. That makes sense, it thinks the data has ended. On inspection, I found quite a lot of blank lines, so there was […]

Categories
Automation Programming

Use PowerShell to Send All Regex Matches to a New File

Yesterday I had to look at a list of stuff on a third-party website and match it up to a list of stuff we control. It took quite a bit of time and some Excel shenanigans to complete the task and as I know it’s going to crop up again, I decided to employ PowerShell […]

Categories
Programming

The type or namespace name ‘ApplicationInsights’ does not exist in the namespace ‘Microsoft’

If you uninstall the Application Insights package from a .NET Core MVC project, you might get a few errors as it can’t “remove all the references” that might have made it into your application. The changes to StartUp.cs will be pretty self-explantory, but elsewhere you will get something a bit more off-the-wall as it references […]

Categories
Programming

Notifications for Web Apps

Although it has been abused with an enthusiasm that borders on the insane, there are good reasons to use the Notifications API in your web apps. For example, you write a mail client that allows the user to request notifications for key contacts… if they are browsing your web-based app, they should get notifications. To […]

Categories
Programming

IISExpress.exe Exited With Access Violation

I was happily typing away at some ASP.NET Core controllers and views, calling a view component to render out some paging links, when this happened… The program iisexpress.exe’ has exited with code -1073741819 (0xc0000005) ‘Access violation’. No exception visible in Visual Studio. No indication of where the error was. Nothing. The Internet supplied links to […]

Categories
Programming

The Software Punk Revolution

Let’s be honest. Our planet is churning out supercodemonsters at an alarming rate. These pinnacles of virtuosity are idols to the false gods of development ego. The pattern has always been there, but in the past it was misdirected enthusiasm. On day one you’d learn how to extend prototypes in JavaScript. On day two, everything […]

Categories
Programming

C# 9 Covariant Return Types

Just a quick note on a neat feature in C# 9 that will allow sub-classes to return a covariant return type… what?! Okay, it allows you to return a more specific, or narrower type. For example, we used to have to return the same type… // parent class… public virtual Literature GetLiterature(…) { return new […]

Categories
Programming Windows

Turn an Old Phone into a Programmable Keyboard

It seems like everyone has a high-quality, expensive, programmable deck on their desk these days. Elgato’s Stream Deck, with it’s glowing LCD buttons, comes in flavours that cost between £100 and £200 (depending on how many buttons you want). It’s beautiful bit of kit that glows its way into the hearts of tech geeks everywhere. […]