How to Perform Snapshot Testing With Verify in C#
In this article, we are going to discuss how to perform snapshot testing on objects using the Verify library. Testing is an important part of our software development pipeline. As developers, we often rely on familiar testing approaches like unit testing, where we...
Persist Values With AsyncLocal in C# Async Flow
In this article, we'll explain the AsyncLocal class and how to persist values across an async flow with the AsyncLocal class in C#. We'll start by describing the challenge that AsyncLocal solves and continue with examples of how it does that. We'll scratch the surface...
Global Query Filters in Entity Framework Core
In this article, we will discuss Entity Framework Core's global query filters and how to use them. We will also consider other scenarios related to using query filters that we need to be aware of. [sc name="github"...
Comparison of Rebus, NServiceBus, and MassTransit in .NET
Messaging systems are the backbone of scalable and distributed applications in .NET. They allow different parts of an application, or even separate applications, to communicate efficiently and reliably. Choosing the right messaging library, Rebus, NServiceBus, or...
Chain of Responsibility Design Pattern in C#
In this article, we will talk about the Chain of Responsibility Design Pattern. We are going to see how to implement this pattern in C# and how it can solve certain design problems. [sc name="github"...
How to Connect a SQLite Database to EF Core
In this article, we'll discuss connecting a SQLite database to an ASP.NET Core Web API using EF Core. So, let's get going. Introduction to SQLite SQLite...
Optimistic Locking vs Pessimistic Locking in .NET
Since the invention of database systems, they have become the primary source of truth for almost every web application's data. As user demands grow, applications scale, and so does the concurrency within the system. Ensuring data integrity and consistency along with...
Early Binding and Late Binding in C#
In C#, method binding refers to associating a method call with the method's code definition. When we invoke a method, the program determines which specific method to execute. This process, known as "binding," can occur at two different times: during compile-time...
How to Use Pointers in C#
In this article, we'll introduce pointers in C#, exploring their syntax, usage in unsafe code blocks, and practical applications with direct memory manipulation. We'll also discuss considerations involved in using pointers in a managed language. [sc name="github"...
Content Negotiation in an ASP.NET Core Minimal API Using Carter
In this article, we'll examine how to implement content negotiation in an ASP.NET Core Minimal API. Since there are several ways to implement content negotiation in .NET APIs, we'll briefly discuss the different approaches and tradeoffs for each. [sc name="github"...
How to Get an Instance of IServiceProvider in .NET
In modern .NET applications, dependency injection is a fundamental design pattern that promotes loose coupling and enhances maintainability. At the center of .NET's dependency injection system lies the IServiceProvider interface, which acts as a service locator for...
Entity Framework Core Best Practices
Entity Framework Core (EF Core) is an object-relational mapper (ORM), enabling us to work with a database using .NET objects, eliminating much of the data-access code we usually need to write. EF Core supports many databases, including SQL Server, SQLite, PostgreSQL,...
How to Prevent Concurrent Execution of a Hangfire Job
In this article, we will see how we can prevent the concurrent execution of a Hangfire job. Hangfire is a wonderful tool for scheduling recurring background jobs. But, if we are not careful, we can encounter strange or intermittent errors caused by concurrent...
Publish MediatR Notifications in Parallel
In this article, we will explore how publishing MediatR notifications in parallel works. Also, we will dive into the advantages and possible pitfalls of using parallel publishing. [sc name="github"...
How to Use the REPR (Request-Endpoint-Response) Pattern in .NET
In this article, we are going to explore the REPR (Request-Endpoint-Response) design pattern in .NET. We'll start our discussion by examining what the REPR pattern entails. Then, we'll go on to see how we can use it in our .NET projects. Finally, we'll look at the...
Mediator Design Pattern in C#
In this article, we are going to talk about a popular design pattern, the Mediator Pattern. We will see how this pattern helps address some design problems and how to implement it in C#. [sc name="github"...
Manage Background Tasks With The IHostedLifecycleService Interface
In this article, we’ll describe the IHostedLifecycleService interface. We'll see how it extends the IHostedService interface and enables finer control over the hosted service lifecycle. Finally, we'll show some practical use cases for the IHostedLifecycleService...
SIMD Accelerated Numeric Types in C#
In this article, let's explore the various SIMD (Single Instruction, Multiple Data) accelerated numeric types in .NET. We'll start by examining what SIMD stands for and how it works in .NET. Then, we'll look at the different SIMD accelerated numeric types available in...
Load Testing ASP.NET Core Web API With JMeter
In this article, we will learn how to load test an ASP.NET Core Web API with JMeter. So let's get going. Introduction to JMeter Load testing is...
StringValues in ASP.NET Core
When developing web applications using ASP.NET Core, we frequently encounter scenarios where we need to manage collections of strings. These collections can originate from various sources, such as HTTP headers, query strings, form data, and configuration settings....
How to Implement Log4net in C#/.NET
In this article, we will learn how to implement Log4net, a logging framework for C# applications, and how to use it effectively. Knowing how to log properly helps us to be more efficient while debugging, monitoring, and maintaining our applications. [sc name="github"...