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"...
Dynamically Change the ServiceLifetime of a Registered Service in .NET
Managing dependencies is essential in modern application development. .NET provides a powerful Dependency Injection (DI) system, with ServiceCollection at its core. Typically, we register a service and use it as is. However, there are instances when we need to change...
Differences Between Record Struct and Record Class in C#
In this article, we'll discuss the differences between record struct and record class in C#. First, we will shortly explain each of the types. Afterward, we'll show and describe each difference between them. [sc name="github"...
Advanced Debugging in C#
In this article, we'll be talking about advanced debugging and inspecting data in C#. We'll be using Visual Studio 2022 to demonstrate all the debugging techniques. For more information about general debugging, we have another article on the basics of debugging, so...