Javatpoint Logo
Javatpoint Logo

LINQ to SQL Insert,Delete and Update Operations

The LINQ to SQL has the facility to maintain the changes whatever we do with the objects like adding, removing, or updating the items in the collection of the object till we submit the changes by using the method SubmitChanges() . After submitting the changes, the LINQ to SQL will translate our actions to SQL and submit the changes to the database.

Syntax of LINQ to SQL Insert/Update and Delete

Here is the syntax of Insert/Update or Delete operations using in LINQ to SQL.

LINQ to SQL Insert Operations

Here is the syntax of using the LINQ to SQL Insert operations query in C# to insert the data in the database.

LINQ to SQL Update Operations

Here is the syntax of using the LINQ to SQL update operation query to update the data in the database.

LINQ to SQL Delete Operations

Here is the syntax of using the LINQ to SQL delete operations in C# to delete the data in the database.

LINQ to SQL Insert, Update, Delete Operations

Before we start to implement the LINQ to SQL Insert, update and delete operations, firstly there is a need to create a database with required tables and map those tables to LINQ to SQL file (.dbml).

Once we create and map the required tables to .dbml file now, we want to show the data in our application. For that, we will right-click on the application->Select Add->New Item->Select Web Form->Give name as Default.aspx and click Ok button.

Now open Default.aspx page and write the code as shown below:

Now open the code behind the file and write the code as shown below:

In the above example, we are implementing LINQ to SQL select, insert, and update, delete operations. Now we will run the application and see the result.

LINQ Crud
Next TopicLINQ to ADO.NET




Help Others, Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA