Posts

Showing posts from October, 2023

ASP.NET Core: Using AutoMapper

Image
AutoMapper is a simple C# library that helps to transform one object into another object. This is a less configuration-based conventional object-to-object mapper library. This object-to-object mapping works by transforming the input object of one type to an output object of a different type.  Why the AutoMapper is needed? The main reason behind using AutoMapper is to make sure that we can hide the important properties of the core object (aka the domain object) from showing them directly to the client.  Let's take an example here, in any Employee Information System the actual Employee Domain object has various properties like Name, DeptName, Designation, Salary, Experience, TasksToPerform, etc. When this object is needed by the Accounting System, it just needs Name, DeptName, and Salary, so instead of passing the Employee object to the Accounting System with unnecessary data, it's better to create a separate ViewModel DTO with necessary properties for Accounting System and map ...

Node.js and Express: Accessing SQL Server Database for CRUD Operations

Image
In this article, we will see how we can use Node.js to build REST APIs using Express.js and access SQL Server Database. We will use mssql package to connect to the SQL Server database and perform CRUD Operations. The reason behind writing this article is to help the new Node.js learners design and Develop database-centric applications while they want to design and develop additional modules with existing business applications. I have already published an article on performing Database Operations using Node.js with Sequelize and PostgreSQL databases. You can read this article from this link . In the article, we will not use Sequelize but instead, we will see how we can use SQL Statements to perform database operations. Step 1: Create a folder named node-sqlaccess. We will use this folder as a project folder.    Open this folder in Visual Studio Code. Open the Terminal window or Command Prompt and navigate to node-sqlacess folder. Run the following command to create package...