Part 5 Insert Update Delete using stored procedures in LINQ to SQL

preview_player
Показать описание
Text version of the video

Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.

Slides

LINQ to SQL Tutorial - All Text Articles & Slides

LINQ to SQL Tutorial Playlist

Dot Net, SQL, Angular, JavaScript, jQuery and Bootstrap complete courses

In this video, we will discuss using stored procedures to perform Insert Update and Delete. This is continuation to Part 4. Please watch Part 4 before proceeding.

Step 1 : Create Insert, Update and Delete stored procedures

Step 2 : In Visual Studio, click on the "View" menu and select "Server Explorer". Right click on "Data Connection" and select "Refresh". Expand "Stored Procedures" folder. Here you should find all the stored procedures.

Step 3 : Drag Insert, Update and Delete stored procedures from the Server Explorer window and drop it on the LINQ to SQL class designer. This will automatically create respective methods with the same name as the stored procedures.

Step 4 : Mapping stored procedures to work with LINQ to SQL
a) Right click on Employee entity on LINQ to SQL designer and select "Configure Behavior" option.
b) In the "Configure Bevior" window, set
Class = Employee
Behavior = Insert
Select "Customize" radio button
From the DropDownList, select InsertEmployee() stored procedure
Map Method Arguments to Class properties
c) Finally click OK
d) In a similar fashion, configure stored prcoedures for Update and Delete operations.

At this point, run SQL profiler and start a new trace. Run the application and perform Insert, Update and Delete. In the SQL profiler trace notice that the respective stored procedures are called as expected.
Рекомендации по теме
Комментарии
Автор

Hi Venkat,
I am bit confused, after mapping store procedure what code need to be write on code behind button click event.

vinodingle
Автор

Hello Venkat,
Your videos are wonderful.  I have learned a lot from you.  However, do you have videos on Insert, Delete, Update, Select using Web Services and Stored Procedure?
Thank you,
Bin

binchan
Автор

Hey Venkat, I have watched and subscribed to many of your video tutorials on you tube and visited your website also. Thank you for all your efforts. They are really great for those of us out here trying to learn this vast subject. I just finished the first 5 tutorials on LINQ to SQL. They move at breakneck speed that I am sort of over helmed by the content. Can you recommend other series I can watch before this series such that don't feel so over helmed by so many points you example per video?

christopherkenn
Автор

hi venkat, i am a very thankful to you for your videos.
can you pls provide me the link of your blog from where i can get these stored procedures and the c# code.

nitinpandey
Автор

I am confused for example you are clicking update button @3:40 to update record (same way you explained in 2nd tutorial) which updates. and then you also assigned a update storeprocedure. so It updates twice?  with code at 3:40 and with sp? since you have the sp update logic why do you need the code on the button click? thanks

skolker
Автор

sir pls give the stored procedure to only insert into other columns except id, as i set it to autoincrement

theengineerguyshiv
Автор

I think this is most stupid video of yours, how could u directly use that bleady windows and configure the behaviour, Then what is the need for that normal linq queries in code behind?
You need to call stored procedure for that directly man and pass parameters so that viewers can understand what r u doing.

fatlossjourneyto