Skip to main content

Posts

Showing posts from December, 2022

Part-1 | .NET7 Web API | SQL Database | VueJS(3.0) - Composition API | CRUD Example

The main objectives of this article are: .NET 7 Web API And Vue(3.0) Application Communication. Install The SQL Server And SQL Management Studio .NET 7 Web API And Vue(3.0) Application Communication: The user requests the VueJS(3.0) application(single page application) then js files are downloaded and run the app on the browser. Since VueJS(3.0) is a single-page application, it depends on API for data to display. API runs at the server that gives JSON response. API communicates with the database for fetching the data. Install The SQL Server And SQL Management Studio: First, install the SQL server on our local machine. So go to  "https://www.microsoft.com/en-in/sql-server/sql-server-downloads" and then install the developer version which is accessible and fully functional. Next, install the SSMS(SQL Server Management Studio) IDE at "https://learn.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms?view=sql-server-ver16" Create A Sample Databas

.NET7 | Razor Pages | EF Core | One To Many Relationships | CRUD Example

In this article, we will implement Razor Pages CRUD operation with one-to-many relationships between the tables using the Entity Framework Core. Razor Pages: Razor Pages is a simplified web application model. Compared with the 'MVC' template, razor pages won't have 'Controllers', which means Razor Page is a combination of  'View' and 'Model'. The route will be configured within the razor page or view. A Razor Page composed with 2 files like '*.cshtml.cs'(Model) & '*.cshtml'(view). One-To-Many Relationship Table SQL Script: For this demo, we will create 2 tables 'Employee'(parent table) and 'EmployeeAddresses'(child table). Between the tables, we make a one-to-many relationship which means one employee record can have multiple records in the employee address table. Employee Table Script: CREATE TABLE Employee( Id int IDENTITY (1,1) NOT NULL, FirstName varchar (200) , LastName varchar (200) , JobRole varchar(50) CON

Entity Framework Core 7 JSON Columns | Mapping | Querying | Updating | Example

In this article, we are going to discuss about EF Core 7 feature that JSON data mapping, querying and updating operation. JSON Document Case Study: Here we can observe a 'Employee' table whose contact details are saved as document data. In general, we have to read it as string data in our dotnet application. But EF Core 7 supports that we can map the JSON document as a normal C# class and also we query them and also we can update the data inside of the document either fully or partially. Fetch JSON As Simple String: First, let's check the simple API endpoint which will fetch data directly which means our 'ContactDetails' column in the database is a simple string. Our table class is like 'Employee.cs'. Employee.cs: public class Employee { public int Id { get; set; } public string? FullName { get; set; } public string? ContactDetails { get; set; } } Our database context is like 'MyWorldDbContext.cs'. MyWorldDbContext.cs: using Dot7.JsonM