Posts

Showing posts from January, 2024

Entity Framework Core 8: Implementing Complex Type and DateOnly TimeOnly support features of Entity Framework Core 8 like

EntityFrameworkCore 8 (EF Core) is a popular Object Relational Mapping (ORM) technology for working with data access. Version-by-version,  EF Core has introduced various features for developers.  In this article, we will see and implement the following two features 1.  Complex Types 2.  DateOnly & TimeOnly Support Using Complex Type While working with the Code-First approach, several times, we need to use the  nested data structure to group similar properties e.g. if we are creating  entities for Employee, Person, Student, then The Address is the complex type  we will need to store an Address for Employees, Persons, and Students.  In this case, instead of having repeated properties for Addresses like Stree, City, etc., we can create an Address class with these properties, and then in  the actual entity class, we can add a property of the type Address.  Now in EFCore 8, this can be directly mapped with a table.  The Table will be created with columns mapped with properties added in 

ASP.NET Core: Using API Key Authentication by using Middlewares

Image
In this article, we will implement the ASP.NET Core 8 Authentication using API Key. There are  several developers widely use API key authentication to secure API endpoints.  To access the API the client must send the valid API Key.  This API key is validated on the server once the client sends it in the HTTP request. The client can send the API key in HTTP request in Request Headers, Request Body, and using the Query Parameter.   The Figure 1 explains the API Key based authentication implementation Figure 1: The API Key Authentication  As shown in Figure 1, the execution takes place as stated in the following points, (the following numbering shows numbers displayed in Figure 1) The client makes an HTTP request by adding a custom header with an API key in it. The request is accepted and it passes through dependencies where the ASP.NET Core DI Registers services for Authentication, Authorization, etc. Make sure that the Authentication and Authorization services are registered in the cont

React.js: using HTML Table as DataGrid for CRUD Operations

  React.js is a powerful and popular JavaScript Library for building interactive User Interfaces. We use React to build a lightweight user interface using components. A component is an autonomous object that has data properties, behaviors (methods), and User Interface. One of the major advantages of component-based libraries and frameworks is that they can be used to build composable User Interfaces using multiple components loaded at a time on the browser this helps to build a complex UI easily for the application. One of the advantages of the component is the re-usability.  When you are building a UI where a similar HTML UI is used repetitively in various components then consider creating a custom re-usable component that can be re-used as a child of various parent components. In this case, a parent component can pass data to this reusable component and manage its rendering based on the data. In a typical web application UI designed using React, we may use (or generally use) an HTML

ASP.NET Core: Implementing Role Based Security with Minimal API

Image
ASP.NET Core Technology Stack is designed to provide superb experience for building modern web apps using Razor Pages, MVC, API, and Blazor. The ASP.NET Core API provides the best feature of building new generation data communication services and this can e further extended to design and develop Microservices based applications. While working with API we create Controllers and then we write HTTP Action methods with logic in it. This approach is traditional as well as increase the coding efforts (sometimes its is useful).  But what if that we want to avoid this additional controller creation and other configuration with it? The minimal APIs are specially written for exactly same requirements where we can avoid unnecessary controllers which we generate using the scaffolding.  Minimal APIs are a simplified approach for building fast HTTP APIs using ASP.NET Core. We can build fully functioning REST endpoints with minimal code and configuration.       But now we have a challenge here is tha