Local Functions vs Lambda Expressions in C#
In this article, we'll discuss the differences between local functions and lambda expressions in C#. Let's...
Conditionally Add Middleware in ASP.NET Core
In this article, we'll explore different techniques on how to conditionally add middleware in ASP.NET Core applications. Let's start!...
Multitenancy in .NET With Orchard Core
Orchard Core, a multipurpose open-source platform built upon ASP.NET Core, offers strong support for multi-tenancy. This article explores the installation and configuration of Orchard Core for multitenancy .NET applications, as well as the setup of multitenancy...
Proxy Design Pattern in C#
In this article, we are going to talk about a structural design pattern, the Proxy Pattern. We will discuss what problem this pattern solves and how to implement it in C#. [sc name="github"...
Working With Semaphore Class in C# and Best Practices
In this article, we'll introduce the semaphore class in C#. We'll compare the semaphore and semaphoreSlim classes and discuss the best practices for using semaphores. [sc name="github"...
What Does the null! Statement Do?
In this article, we are going to discuss the null! statement in C#. First, we will explore its construct, and function in our programs. Then, we will examine various situations where we can use this statement in our applications. [sc name="github"...
How to Use FakeLogger to Test Logging Code in .NET
In software development, logging, and unit testing serve as foundational tools, each actively contributing to the reliability and functionality of our applications. While unit testing promptly alerts us to changes in our application's business logic, logging actively...
How to Ignore a Property in AutoMapper
In this article, we will explore key techniques to ignore property in AutoMapper. We will use the Ignore() method, the Ignore attribute, and the DoNotValidate() method. We will also discuss when and how to use each of the methods mentioned. [sc name="github"...
Flattening Nested Collections in C#
In this article, we'll explore flattening nested collections in C#. We'll examine different approaches for handling from simple to complex data structures, offering practical guidance to effectively flatten nested collections within our C# applications. [sc...
How to Properly Set Connection Strings in ASP.NET Core
In this article, we will delve into connection strings providing insights into their functionality, and best practices for safeguarding sensitive data. [sc name="github"...
Find Differences Between Collections With the LINQ Except Method in C#
When working with collections in C#, we sometimes need to manipulate them by performing operations such as comparisons, mergers, or finding set differences between them. The LINQ Except method comes in handy when we want to find the set difference between two...
Differences Between Span and Memory in C#
In this article, we'll briefly explain the Span and Memory .NET types and mention their primary usage. Furthermore, we will explore the differences between Span and Memory in C# in depth and conclude with some general tips on when to use one type over another. [sc...
Adding a Custom Header Parameter to All API Endpoints in Swagger
Within the .NET ecosystem, Swagger stands out as an essential tool, enabling developers to produce interactive and comprehensive API documentation. Header parameters play a crucial role in carrying important metadata in HTTP requests. Specifically, this metadata...
Weak Events in C#
We use weak events in C# to avoid memory leaks in event-based applications. Let's learn more about weak events, why they're needed, and how to implement them. [sc name="github"...
Retrying Failed HttpClient Requests in .NET Using Polly
In this article, we will explore the different approaches to retrying failed HttpClient requests using Polly. We will also discuss the advantages and disadvantages of each retry strategy, from simplest to most sophisticated. [sc name="github"...
How to Use the LINQ ToDictionary Method in C#
In this article, let's describe how to use the LINQ ToDictionary() method in C#. We will start by defining this method and how it works. Then, we will proceed to show several ways of invoking it. Ultimately, we will discuss different situations where we can utilize...
How to Serialize a PascalCase JSON.NET JObject to camelCase
In this article, we’re going to learn how to serialize a PascalCase JObject to a camelCase format. We will do this in two ways by using the most familiar JSON library in the .NET ecosystem which is Newtonsoft.Json. [sc name="github"...
Bouncy Castle Cryptography Library for .NET
Cryptography remains an ever-important topic in building modern security-minded applications. Bouncy Castle is a cryptography library for .NET that allows users to build robust cryptography features. In this article, we will cover just a few important capabilities...
Comparing ExecuteAsync() and StartAsync() Methods from the BackgroundService Class in .NET
Due to the emerging significance of running background tasks, .NET Core has given us new ways of achieving it. BackgroundService is another tool in our toolbox with methods ExecuteAsync() and StartAsync() being the central components. In this article, we will compare...
How to Mock IConfiguration.GetValue in ASP.NET Core
In this article, we'll take a closer look at how we can mock IConfiguration.GetValue when writing unit tests in ASP.NET Core. Let's start!...
Embedded Resources in .NET
We've covered resources in a couple of our previous articles. In Localization in ASP.NET Core, we delved into .NET localization, touching upon resources since XML files utilized for localization fall under .NET resources. We also discussed resources in our article,...