dotNet Core

Entity Framework Core 3.1 Bug vs 2.2, Speed and Memory During Streaming

Full source code available here. A while ago I wrote a blog post about the advantages of streaming results from Entity Framework Core as opposed to materializing them inside a controller and the returning the results.

Getting Started with Elasticsearch, Part 2 - Searching with a HttpClient

Full source code available here. In the previous blog post I showed how to setup Elasticsearch, create and index and seed the index with some sample documents. That is not a lot of use without the ability to search it.

Registering Multiple Implementations of an Interface in ASP.NET Core with Autofac

Full source code here. A few weeks ago I wrote a post about using dependency injection to pick between two implementations of an interface. It was a solution I was not very happy with because it meant I had to new up the implementations inside a factory or I had to use service collection to instantiate all implementations of the interface and then use a piece of code to return the one the was wanted.

Selectively Caching Values Inside HttpResponseMessage with Polly – caching series 3/3

Full source code here. Want to learn more about Polly? Check out my Pluralsight course on it. This is the last of three posts on caching with Polly. The first showed how to selectively cache HttpResponseMessages based on the status code of the response.

dotnet new failing with Error: Invalid parameter(s)

If you are using Visual Studio Code and you want to add a new project to your workspace, the easiest thing to do is something like - dotnet new xunit -f netcoreapp2.

Caching Values Inside HttpResponseMessage with Polly – caching series 2/3

Full source code here. Want to learn more about Polly? Check out my Pluralsight course on it. In this, the second of three posts on caching in Polly, I will show how to cache the values returned inside a HttpResponseMessage as opposed to caching the response with all its various elements.

How to Dependency Inject a Service from Startup back in Program

Full source code here. While writing some recent blog posts on HttpClientFactory I had to work with some of the obscure features of ServiceCollection and dependency injection in .NET Core 2.

Dynamically Updating the Request Header of a HttpClientFactory Generated HttpClient, Part 2

Full source code here. This is a alternative to the approach described in a previous post. On a slack channel there was some discussion around the use of a little known extension method on HttpClientBuilder, ConfigureHttpClient.

How to Turn Off Console Logging for Kestrel in .NET Core

This post is mostly a note to myself. I am often annoyed with the amount of logging to the console that occurs when I start a Kestrel hosted application and I can never remember how to turn it off.

HttpContent ReadAsAsync with .NET Core 2

Full source code available here. If you are used to using HttpContent.ReadAsAsync you might be surprised to learn that it is missing from .NET Core 2. You can try adding Microsoft.