Saturday, October 16, 2021

ASP.NET Core CRUD Operations With Paging, Sorting, Searching, and Export Data Option

 Introduction

In this article, I will illustrate how to create an APS.NET core MVC web application using EF core. The main features of this application create a CRUD operation, faster Paging, Sorting, Searching, and Export Data to CSV, PDF, Copy to Clipboard, and print data as well.

After finishing this article you will learn, how to create a complete AP.NET Core web application with EF core and Generic Repository Pattern. The major advantage of this application is faster paging, sorting, filtering operation by implementing jQuery Data tables on the front end side.

Prerequisites

01. Visual Studio 2017
02. Install .NET Core 2.0.0 or above SDK
03. MSSQL Server 2008 or above

Technology I Used

01. ASP.NET Core
02. C#
03. Generic Repository Pattern
04. ASP.NET build in Dependency Injection
05. EF Core
06. LINQ
07. Razor Tag Helpers
08. jQuery Datatable
09. jQuery UI
10. Sweetalert 2
11. Bootstrap
12. REST API

Steps to Creating this Project

01. Open VS 2017 and Create an ASP.NET Core web application in Visual Studio 2017

02. Select MVC Project Structure from VS Template Project

03. And also create an ASP.NET Core class library project for EF Core data access layer. Here I have used the generic repository pattern for application data access.

04. Overall Project Structure

Create MOC Data in MSSQL Database

Using the following SQL script I have created 5 luck data for testing application data load, search and pagination performance. jQuery data tables render data very fastly from the server side by paging.

Create a Model Class:

DB Connection: appsettings.json

Startup.cs

Create data: Ajax Request

Data tables: Javascript code

File location in the project:
~Sln.jQueryDatatables\jQueryDatatables\wwwroot\js\PersonalInfo\PersonalInfo_Datatable.js

Data tables: C# Code

Export All Data to CSV

For export, all data I have used CSV helper. From Nuget library just install CsvHelper by following command in PMC,
Install-Package CsvHelper.

Conclusion

This is a very basic CRUD application using ASP.NET .NET core but advance in data operation. The application performs a faster data loading operation, which is implemented by jQuery data tables. Application successfully loaded 5 luck dummy data with paging within a few seconds. Searching, filtering, and paging are pretty fast as well. For future work, I will implement the login module in this project.

Thanks for your valuable time. I hope you fully understand and enjoyed my article. For further more query please email me at teamechno360@gmail.com








No comments:

Post a Comment