LINQ with DML Queries in C# – Programming, Pseudocode Example, C# Programming Example
Collection Linq

LINQ with DML Queries in C#

Here the following concepts are explain about LINQ with DML Queries.
DML
Data Manipulation Language (DML) statements are used for managing data within schema objects. They are:

  • Select
  • Insert
  • Update
  • Delete

Select

The SELECT statement returns a result set of records from one or more tables. The SELECT statement has many optional clauses: WHERE, ORDER BY, GROUP BYFor Example:

  • A Table name as tbl_Student.
  • This table contain the following columns: StudentID, Firstname, Lastname, Location, Email.

Insert

To execute a SQL Insert, just add objects to the object model you have created, and call SubmitChanges on the DataContext.The following example, Let insert  a new Student detail into tbl_Student table. This table contain the following columns: StudentID, Firstname, Lastname, Location & Email.

Update

To Update a database entry, first retrieve the item and edit it directly in the object model. After you have modified the object, call SubmitChanges on the DataContext to update the database.The following example, Let retrieve a Student detail from tbl_Student table who are all from Location Pondy. Then change Location = “Pondy” to “Puducherry”. Finally SubmitChanges is called to send the changes to database.

Delete

To Delete an item, remove the item from the collection to which it belongs, and then call SubmitChanges on the DataContext to commit the change.The following example, delete a Student detail from tbl_Student table who are all from Location ‘Chennai’. Finally SubmitChanges is called to send the changes to database.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: