EF Core, String Interpolation and SQL Injection

EF Core has always provided support for inline SQL queries. This means that you could pass a T-SQL query to be executed through the current DbContext. A typical example would look like this: var term = "some search term"); var blogs = db.Blogs.FromSql($"SELECT * FROM dbo.Blogs WHERE Title = {term}") .OrderBy(b => b.Url) .Select(b => b.Url); This feature is great if you need to call a table function etc. I would urge that this feature is used in moderation and with careful consideration. Calling raw T-SQL requires that developers understand the potential security or performance implications …[read more]


Improving EF Core performance with Compiled Queries

EF Core 2.0 is production ready and it's now fully RTM. Therefore, I hope that by now you have had the chance to take it for a spin and use it in your code. There are many compelling reasons why you would want to use EF Core such as performance, portability and size being. The latest release of 2.0 has added a number of new features making it a very compelling ORM. Friendly reminder: EF Core can run both on the full .NET Framework and .NET Core. Don't let the "core" in the name confuse you. Today I …[read more]


Working with Application Insights and NLog in Console apps (.NET)

Application Insights is a logging platform that allows the collection and, more importantly, the collation of log data from any application. It's primarily optimised and designed to work with web frameworks such as Node.js, ASP.NET (Core too) or PHP etc. You choose the language and AppInsight's got you covered. There are, however cases that you want to do some logging (and you should) from a different type of application, like an Azure WebJob or a Console App. AppInsights works flawlessly with web frameworks because under the hood it creates an HttpHandler that intercepts request/response data. This means …[read more]


Scaffolding DbContext and Models with EntityFramework Core 2.0 and the CLI

EF Core 2.0 has been out for a few weeks now. If you're looking at an ORM for your .NET application then EF Core should be at the top of the list of possible options. I say at the top and not the only one because depending on the project requirements, some features may be missing. For example, EF Core cut ties with .edmx so if you want to stick with the designer feature you will need to use EF6. There are other limitations so make sure you have a look at this post for API changes in 2. …[read more]


Getting started with public speaking, a guide for technical people

Hello new and seasoned speakers! Let's start with a definition on public speaking: Public speaking Speaking at conferences, user groups or anytime you have to stand in front of people and talk about something in a structured way. And the Merriam Websterdictionary definition of Public Speaking: The act or process of making speeches in public The art of effective oral communication with an audience It's funny how context makes such a big difference. If you're at the pub/bar/coffee shop with friends/colleagues and the conversation happens to turn technical you could spend hours talking about a "technology, language, …[read more]