Creating Conditional Required Attributes for Validation in .NET Web API
Whether seasoned or just getting started in the .NET world, we've all encountered situations where we need to conditionally validate some attributes of data based on specific conditions. In this article, we're going to learn about creating conditional required...
How to Log a Class and Method Names Using Serilog
Developers must implement an efficient logging system to maintain and troubleshoot applications effectively. One popular logging library that provides powerful logging capabilities is Serilog. In this article, we will talk about how to log class and method names using...
How to Overwrite DateTime.Now During Testing in .NET
In this article, we'll look closer at how we can overwrite the DateTime.Now property when testing applications in .NET. Let's dive in!...
New Features in C# 12
In this article, we will explore new features in C# 12. We will describe primary constructors, collection expressions, inline arrays, and other newly introduced features. We'll need the latest Visual Studio 2022 or .NET 8 SDK to try each of these new C# 12 features,...
Using Fluxor for State Management in Blazor
In this article, we will review the Flux pattern with its benefits, and drawbacks in general. Then we will take a look into how Fluxor implements this pattern. Finally, we will learn how to use the library using an example Blazor application. Since the .NET Core term is fading away slowly, let's remember how it...
How to Get the Number of Files in a Folder With C#
In this article, we are going to see how to get the number of files in a folder. C# provides several methods to determine file counts within a folder, each tailored for specific use cases. [sc name="github"...
The Difference Between RESTful APIs and Web APIs Using ASP.NET Core
In this article, we will discuss the difference between RESTful APIs and Web APIs using the ASP.NET Core framework. We'll begin by explaining what exactly an API is. Then, we'll explain the meaning of REST and RESTful. After that, we will delve into Web APIs. Finally,...
Parsing HTML With AngleSharp in C#
In this article, we will be exploring parsing HTML with AngleSharp in C#. AngleSharp is a powerful library in C# that gives us the ability to parse angle bracket-based hyper-texts like HTML, SVG, MathML, as well as XML. Our focus in this article will be to introduce...
Comparing for and foreach Loops in C#
In this article, we will compare the for and foreach loops. Iterating through arrays and lists is fundamental when learning any programming language. C# offers different ways to achieve this, such as using while, for, and foreach statements. But, what about the...
How to Get appsettings.json Content as a Dictionary in ASP.NET Core
When working with ASP.NET Core applications, storing configuration settings in the appsettings.json file is common. While the appsettings.json file offers a convenient way to structure configuration data; there is a common need to retrieve this data in a format that...
How to Pass Complex Parameters to Theory in xUnit
In this article, we are going to explore different ways to pass complex parameters to Theory test methods in xUnit. Let's start...
MapControllers vs MapControllerRoute Routing in ASP.NET Core
In this article, we will examine the two key routing methods in ASP.NET Core: MapControllers vs MapControllerRoute, and their differences. They are vital in directing HTTP requests to the appropriate controller actions. [sc name="github"...
Tools and Best Practices for Secret Management in .NET
In this article, we will talk about the tools and best practices for secret management in .NET applications. Every application has values it wishes to keep hidden. One of the critical aspects of security in software development is how we handle secrets. Examples of...
Lazy Loading and Eager Loading in Entity Framework Core
In this article, we will learn about the loading strategies we can employ in EF Core. These strategies, namely Lazy Loading and Eager Loading control how data is fetched from the database. We will also delve into performance impacts and considerations for choosing one...
How to Correctly Implement IDisposable Interface in C#
In this article, we will show how to correctly implement the IDisposable interface. We will focus on key aspects with a clear explanation. The IDisposable interface in managed code gives us a tool to manage resource cleanup. By implementing IDisposable, we can also...
How to Divide Data Into Batches With LINQ
In software development, it is often necessary to divide data into manageable batches for more efficient processing and improved application performance. In this article, we will look at some approaches to dividing data into batches using LINQ methods, with the C#...
Probabilistic Programming in C# With Infer.NET
With the increasing progress and interest in AI and Machine Learning, keeping track of and understanding the technologies behind powerful AI and ML systems is essential. One of these technologies is Probabilistic Programming. In this article, we will learn what it is...