In this article, we’ll learn how to perform CRUD operations with .NET Core 3.0 and Visual Studio 2019. We will use a dapper to perform CRUD operations.
CREATE TABLE [dbo].[Job]( [JobID] [int] IDENTITY(1,1) NOT NULL, [JobTitle] [nchar](250) NULL, [JobImage] [nvarchar](max) NULL, [CityId] [int] NULL, [IsActive] [bit] NULL, [CreatedBY] [nvarchar](50) NULL, [CreatedDateTime] [datetime] NULL, [UpdatedBY] [nvarchar](50) NULL, [UpdatedDateTime] [datetime] NULL, CONSTRAINT [PK_Job] PRIMARY KEY CLUSTERED ( [JobID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
CREATE PROCEDURE [dbo].[SP_Add_Job] @JobTitle NVARCHAR(250) , @JobImage NVARCHAR(Max) , @CityId int , @IsActive BIT , @CreatedBY NVARCHAR(50) , @CreatedDateTime DATETIME , @UpdatedBY NVARCHAR(50), @UpdatedDateTime DATETIME AS BEGIN DECLARE @JobId as BIGINT INSERT INTO [Job] (JobTitle , JobImage , CityId , IsActive , CreatedBY , CreatedDateTime , UpdatedBY , UpdatedDateTime ) VALUES ( @JobTitle , @JobImage , @CityId , @IsActive , @CreatedBY , @CreatedDateTime , @UpdatedBY , @UpdatedDateTime ); SET @JobId = SCOPE_IDENTITY(); SELECT @JobId AS JobId; END;
2. Microsoft.EntityFrameworkCore.SqlServer.Design
3. Microsoft.EntityFrameworkCore.Tools
4. Dapper
In the Interface folder, add a new interface namely “IDapperHelper” and copy the below code and paste in that class.
using Dapper; using System; using System.Collections.Generic; using System.Data; using System.Data.Common; using System.Linq; using System.Linq.Expressions; using System.Threading.Tasks; namespace CoreDemo_3_0.Interfaces { public interface IDapperHelper : IDisposable { DbConnection GetConnection(); T Get<T>(string sp, DynamicParameters parms, CommandType commandType = CommandType.StoredProcedure); List<T> GetAll<T>(string sp, DynamicParameters parms, CommandType commandType = CommandType.StoredProcedure); int Execute(string sp, DynamicParameters parms, CommandType commandType = CommandType.StoredProcedure); T Insert<T>(string sp, DynamicParameters parms, CommandType commandType = CommandType.StoredProcedure); T Update<T>(string sp, DynamicParameters parms, CommandType commandType = CommandType.StoredProcedure); } }
In this article, we have to show Create and Used PIPE in angular
In this article, we have to show Create and Used PIPE in angular
In this article, we have to show Create and Used PIPE in angular
View Comments
It is perfect time to make some plans for the longer term and it is time to be happy. I have read this post and if I could I desire to recommend you some attention-grabbing issues or tips. Perhaps you could write next articles regarding this article. I wish to learn more things about it!
thanks for sharing this article. this post is very helpful.
Hello Faisal . Please We wish you do this same project this time with BLAZOR
Thanx Faisal for this article . .
I m really impressed by how you use SQL Server Stored Procedures in CRUD Operations.
Thanks for reading and valuable feedback!