How to Create an Outer Join in LINQ – (Left and Right)
In this article, we'll discuss how to create an outer join in LINQ. Most used are left and right outer join, but we'll also talk about less common ones. It's hard to find an application that doesn't rely on data. We often use just a single data source. But sometimes...
Read a Text File Without Specifying the Full Path in C#
In .NET applications, reading text files is essential for tasks like loading configurations, processing data, and parsing logs. In this article, we look at the file's relative and absolute paths and set up a new project to read a text file using its relative path. Tuples are a useful and practical .NET structure. In this article by David...
How to Fix CORS Error With AnyOrigin and AllowCredentials
In this article, we will learn how to fix the CORS protocol error with AnyOrigin and AllowCredentials in ASP.NET Core (The CORS protocol does not allow specifying a wildcard (any) origin and credentials at the same time). We assume you know the basics of CORS and how...
How to Add Unique Constraints to a Property in EF Core Code-First
In this article, we'll see how we can apply unique constraints to a property in EF (Entity Framework) Core using the code-first approach. ...
Difference Between Build and Publish in Visual Studio
Has anyone ever wondered about the difference between the build and publish functions in software development? As we know, both the build and publish are important steps in software development, especially when using Visual Studio for .NET applications. Let’s check...
Fastest Method to Check if a Date Is Less Than or Equal to Today’s Date in C#
In our applications, there may be a need to check if an input date string is less than or equal to today's date. This information is crucial for various scenarios, including scheduling events, validating user-entered dates, and updating entities in our database. In...
How to Inject a DbContext Instance Into an IHostedService
In this article, we'll take a look at how to inject a DbContext instance into an IHostedService. We'll also point out some important concepts we should be aware of. Do you know how to throw and catch all exceptions...
Single and Split Queries in Entity Framework Core
Entity Framework Core (EF Core) offers developers two powerful querying strategies: Single and Split Queries. In this article, we'll delve into the pros and cons of each, helping us make informed decisions for efficient data retrieval. The sample in our repository...
Clean Architecture in .NET
In this article, we are going to discuss Clean Architecture in .NET. So let's get going. [sc name="videolink" videotitle="Clean Architecture with...
How To Check if a URL Is Valid in C#
In the world of web development using .NET, it's crucial to make sure the web addresses (URLs) our application uses are correct and safe. In this article, we will understand the basics of how to check if a URL is valid in C#. We'll include some easy-to-understand code...
Using Serilog with Microsoft’s ILogger API
In this article, firstly we will explore how to integrate the Serilog logging package with Microsoft's ILogger API. We will then compare the output of both logging methods to highlight the difference. If you're new to Serilog, we recommend reading our article...
How to Get the Number of Weekdays Between Two Dates in C#
Manipulating date and time values is a common programming problem in many applications. Have you ever wondered how we can calculate the number of weekdays between two dates? Knowing how to do this can be crucial in scheduling, project management, or resource...
How to Get the Number of Lines in a Text File in C#
In C#, understanding how to count lines in a text file efficiently is a fundamental skill. This seemingly simple task is essential, especially in data manipulation, analysis, or validation scenarios. Whether we are dealing with log files, configuration files, or large...
Parallel.ForEachAsync() and Task.Run() With When.All in C#
Parallel programming is a common and broad concept in the .NET world. In this article, we compare two well-known methods we use to achieve it when running a repetitive asynchronous task. We take a look at how they behave under the hood and compare the pros and cons of...
Calculate the Difference in Months Between Two Dates in C#
Calculating the difference in months between two dates is a useful skill for C# developers. Having this knowledge helps us in tasks such as subscription management and tracking course durations. In this article, we learn how to use DateOnly, DateTime, and TimeSpan...
How to Call SignalR Hub from Controller in ASP.NET Core
In this article, we will look at how to call a SignalR Hub from an ASP.NET Core controller. If you are unfamiliar with setting up SignalR in your server and/or client application, check out our article for more information. [sc name="github"...
How to Check if a Number Is Positive or Negative in C#
In programming, it is very crucial to figure out whether a number is positive or negative. This article will walk through different ways to do that in C#. We will discuss in detail some of the very common ways to evaluate if a number is positive or negative,...