Hey, I'm Steven a .NET Developer and Freelancer in Zurich, Switzerland. I am a Microsoft MVP. Also, this blog is open source on GitHub.

Older Posts

Preview image blogpost

Gracefully Handling Entity Framework Exceptions with EntityFramework.Exceptions

Working with databases can sometimes be daunting, mainly when errors occur. These errors or exceptions can be due to many reasons, such as constraint violations, connection issues, or syntax errors. Entity Framework throws a generic DbException or DbUpdateException for most of these database issues. But we cand get more specific exceptions based on the concrete "problem"! That's where EntityFramework.Exceptions comes in.

Read the whole article

Preview image blogpost

.NET Framework 4.8 to .NET 6 migration

I was recently tasked to migrate an application with around 150 projects from the "old"It is still supported .NET Framework 4.8 to a recent .NET 6. As the application is still under development and used, the migration should be done step by step over time in iterative steps rather than a big bang refactoring. This blog post will go a bit into more detail about how I approached the situation and what I learned.

This is a highly subjective post, and there are plenty of ways of approaching it - so take it with a grain of salt and mileage may vary.

Read the whole article

Preview image blogpost

Three tricks with Dictionary

In this short blog post, I want to showcase three nice tricks you can do with everybody's favorite data type: the dictionary.

It is a versatile data structure, and we can make it even more versatile!

Read the whole article

Preview image blogpost

Overload resolution in C#

On a recent LinkedIn Post from Saeed Esmaeelinejad, he asked what is the outcome of:

bool flag = SomeMethod();

M(flag ? 1 : 2);

void M(long number) => Console.WriteLine("long");
void M(short number) => Console.WriteLine("short");

What is the outcome?

Read the whole article

Preview image blogpost

Why I like and prefer xUnit

In almost all of my projects, I only use xUnit, and here is a small love letter. Especially the one fact I do think makes it a good choice!

Read the whole article

Preview image blogpost

LINQ: Select.Where or Where.Select?

LINQ is a very powerful tool for querying data. As the majority of functions are built on top of IEnumerable<T> and it, in most cases returns IEnumerable<T> as well, it is very easy to chain multiple functions together. That leaves you with a question: which one should I use, Select.Where or Where.Select?

Read the whole article

Preview image blogpost

Missing Stack trace when eliding the await keyword

You may have heard that when you elide the await keyword in a method that returns a Task or Task<T>, you lose the stack trace. Buy why does that happen? Let's find out!

Read the whole article

Preview image blogpost

Create your own Mediator (like Mediatr)

In this blog post, I'll show you the fundamentals of the Mediator pattern and how to implement it in your application from scratch. And yes, we basically implement the famous MediatR library.

Read the whole article

Preview image blogpost

C# 12: Collection literals

A new feature is hitting C# 12 and it is called Collection literals. In this blog post, I will show you what it is and how it works.

Read the whole article

Preview image blogpost

How does List work under the hood in .NET?

A List is one of the most used data types in .NET. You can dynamically add elements without taking care of how that happens. But do you know what is going on under the hood?

Read the whole article

An error has occurred. This application may no longer respond until reloaded. Reload x