Quantcast
Channel: Code – no dogma blog
Browsing all 132 articles
Browse latest View live

Getting Error Messages and Status Codes from Typed HttpClients

Full source code here. I have been using HttpClientFactory for a while and have generally preferred using named clients over typed clients. With a named client you get the HttpClient just before you...

View Article


Image may be NSFW.
Clik here to view.

Streaming Results from Entity Framework Core and Web API Core

Full source code here. The code provided will not compile until you make a change in seeder.cs, the way it’s written it generates 500,000 rows in a local db. Set this to whatever value you want. In...

View Article


Image may be NSFW.
Clik here to view.

Simmy Chaos Engine for .NET – Part 1, Injecting Faults

Full source code here. For quite a while I have been writing, presenting and making videos about using Polly to make applications more stable. With this post I’m starting a series on how break your...

View Article

Image may be NSFW.
Clik here to view.

Simmy Chaos Engine for .NET – Part 2, Resilience and Injected Faults

Full source code here. I wrote a blog on using a Simmy Fault policy a few days ago, it is very simple to use by itself, but it is far more useful when used in combination with a resilience policy. Take...

View Article

Simmy Chaos Engine for .NET – Part 3, Adding Latency

Full source code here. This is the third in my series on chaos engineering with Simmy. The first two posts dealt with the fault policy throwing exceptions and returning failed responses rather than...

View Article


Accessing the HttpContext from the Constructor of a Controller or a Dependency

Full source code here. There are times when you may need to access the HttpRequest from places that it is not normally available such as the constructor of a controller or the constructor of a service...

View Article

Registering Multiple Implementations of an Interface with Service Collection...

Full source code here. This is a simplistic approach to the problem and assumes that the dependencies created by the factory do not in turn have their own dependencies. This deficiency could be...

View Article

Simmy Chaos Engine for .NET – Part 4, Doing Some Real Damage, Dropping a Table

Full source code here. Up until now the Simmy examples I’ve written have thrown exceptions, changed successes to failures or slowed down a request. None of these did any real damage to your system, and...

View Article


Registering Multiple Implementations of an Interface with Service Collection...

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...

View Article


Simmy Chaos Engine for .NET – Part 5, Breaking Your Own Code

Full source code here. The blog posts I have written so far about Simmy all deal with the scenario where you don’t have control over the source code that you want to break, in these cases Simmy...

View Article

Passing Configuration Options Into Middleware, Services and Controllers in...

Full source code here. I recently hit a problem where I needed to reload configuration settings as they changed, fortunately this is relatively straightforward when using the IOptionsMonitor, in .NET...

View Article

Simmy Chaos Engine for .NET – Part 6, Configuring Policies Dynamically

Full source code here. Simmy chaos policies have configurable options, via these options the polices can be turned on or off, have the rate at which they fire set, and in the case of the latency...

View Article

Simmy Chaos Engine for .NET – Part 7, Using a Random Chaos Policy

Full source code here. This post builds on the previous one where I added chaos policies to a registry and dynamically configured their settings via a config file. In that example the chaos policy used...

View Article


Image may be NSFW.
Clik here to view.

POST with HttpClient and Basic Authorization

Full source code here. A non .NET developer friend asked me to help him write a sample C# application that exercises a POST endpoint he wrote, it requires Basic authorization. After a quick search I...

View Article

Image may be NSFW.
Clik here to view.

Fluent Validation in ASP.NET Core 3.1

Full source code available here. This is an update to a post I wrote in 2017 talking about Fluent Validation in ASP.NET Core. The example is the same but there has been few updates. The first is how...

View Article


Simple Action and Action Examples

Full source code available here. A junior engineer colleague of mine recently asked me “how the f*** do I call this method?”. Seemed like a reasonable question. It was a method that took a complicated...

View Article

Streaming Results from Entity Framework Core and Web API Core – Part 2

Full source code available here. Some time ago I wrote a post showing how to stream results from Entity Framework over Web API. This approach a few benefits – the results would not be materialized in...

View Article


Simple Func and Func Examples

Full source code available here. About a month ago I wrote a post with a simple explanation of how to use methods that take Action or Action<T> as parameters. Actions themselves take 0 to 16...

View Article

AutoMapper, ProjectTo() – Static Version

Full source code available here. I’ve been using AutoMapper for quite a few years, but one of the features that I like the most is the ProjectTo method. When using Entity Framework it lets me reduce...

View Article

Image may be NSFW.
Clik here to view.

AutoMapper, ProjectTo() – Instance Version

Full source code available here. In my previous post I showed how to use the wonderful AutoMapper ProjectTo() feature, the demo code shown worked with AutoMapper up to v8.1.1. It looked like this –...

View Article
Browsing all 132 articles
Browse latest View live