Posts

Angular 15: Calling the REST API with RxJS CombineLatest

Image
This article is an extension of my previous article . In the previous article, we have seen how to make parallel HTTP calls with RxJS forkJoin() method. In this article, we will use the combineLatest() operator of the RXJS. We use the combineLatest() operator when we need to call multiple APIs and combine them for some processing before returning the result. The best use of this operator is when you have multiple, long-lived observables that rely on each other for some calculation or determination. The use case is that the Angular application wants to access product information of different categories from various REST APIs but the Angular Application wants to show all products of received categories on UI by combining them. Figure 1 explains the use case. Figure 1: Using the combineLatest The combineLatest() operator accepts Observables by accessing REST APIs, and then further allows us to add the code to process these observables as per our requirements in the Angular client applicat

Angular 15: Performing Parallel HTTP Calls to REST APIs using RxJs 7.8

Image
In this article, we will see the mechanism for accessing external REST APIs by making parallel calls using RxJs.  Angular, being the great framework for building complex front-end apps, various times we need to make HTTP calls to REST APIs to fetch data to show on UI. Of course, Angular provides HttpClientModule and HttpClient classes to manage asynchronous HTTP calls. The HttpClient provides get(), post(), put(), and delete() methods to perform HTTP operations and all these methods return an Observable object.  Objeservable is the most basic building block provided in RxJs. An Observable represents a set of values received over any time, this means that when the HTTP call returns data from REST API it is immediately delivered to UI so that the UI can be updated.  There is one more use case that must be considered which makes parallel HTTP calls to REST APIs to fetch data. Here, the challenge is how to collect these multiple observables at a time and pass them to UI? Figure 1 shows the

Implementing Distributed Caching in ASP.NET Core 6 using the Redis Cache In Microsoft Azure

Image
In this article, we will implement distributed caching for ASP.NET Core 6 applications using Redis Cache in Microsoft Azure. In highly responsive web applications as well as in Microservices applications caching plays a very important role. We use caching to store data so that it can be made available to the application at a fast speed when it is required. In ASP.NET Core, we can have caching implemented using In-Memory Cache and Distributed Cache. The Caching Concept A Cache is a mechanism using which the frequently demanded data is stored for a specific duration. Typically, the data required for searching can be stored in the cache and hence this helps to reduce the number of calls to the actual database. Since the data is immediately available to the application, the number of resource requirements e.g. waiting time for the Db Connections can be reduced and hence this results in the performance increase of the application.  The question is what type of data can be stored in the cach

Implementing Server-Side Pagination using ASP.NET Core API and React.js 3

Image
In this article, we will perform server-side pagination using ASP.NET Core API, Entity Framework Core, and the React.js front-end. We should choose the option of server-side pagination when the server returns a large amount of data. The pagination makes sure that the front end is provided with a limited set of data so that the response to the client application is as lightweight as possible. To implement the code for this article I have used the Northwind database. Scrips for the Northwind can be downloaded from this link .    Figure 1 will provide an idea of the implementation   Figure 1: The Application Implementation    For fetching a specific number of records from the table, we can use LINQ with Skip() and Take() methods. I have used the LINQ with Entity Framework Core to implement the server-side pagination.   Once the Northwind database is created, we can see various tables in it. Some of the tables contain Null values. So I have used the query as shown in Listing 1 to create a

Uploading Excel File to ASP.NET Core 6 application to save data from Excel to SQL Server Database

Image
Recently, while conducting a session on ASP.NET Core 6, my client raised a query regarding uploading excel files to the ASP.NET Core MVC application and then further saving data from excel to the SQL Server Database table. I gave him the solution and then thought to write a post on it. As we all know, the Excel Workbook is one of the most heavily used files to save data. But to persist data it is recommended that it should be stored in an SQL Server database.  If the data is stored in an SQL Server database it can be queried easily.  Figure 1, explains an implementation of the application which we are going to discuss in the article. Figure 1: The ASP.NET Core That accepts Excel files and then further store data from Excel Files in SQL Server Database The   ExcelDataReader.DataSet Library To read excel files in ASP.NET Core applications, we need to use the ExcelDataReader.DataSet package. This is a lightweight and fast library for reading Excel files in .NET applications. This is writt