Part 2 Insert Update Delete using LINQ to SQL04:33

  • 0
Published on June 1, 2017

Link for all dot net and sql server video tutorial playlists

Link for slides, code samples and text version of the video

In this video, we will discuss performing Insert Update and Delete using LINQ to SQL. We will continue with the example, we worked with in Part 1. In Part 1, we discussed performing a Select using LINQ to SQL. Please watch Part 1 before proceeding.

Insert using LINQ to SQL
using (SampleDataContext dbContext = new SampleDataContext())
{
Employee newEmployee = new Employee
{
FirstName = “Tim”,
LastName = “T”,
Gender = “Male”,
DepartmentId = 1,
Salary = 55000
};

dbContext.Employees.InsertOnSubmit(newEmployee);
dbContext.SubmitChanges();
}

Update using LINQ to SQL
using (SampleDataContext dbContext = new SampleDataContext())
{
Employee employee = dbContext.Employees.SingleOrDefault(x =] x.ID == 8);

employee.Salary = 65000;

dbContext.SubmitChanges();
}

Delete using LINQ to SQL
using (SampleDataContext dbContext = new SampleDataContext())
{
Employee employee = dbContext.Employees.SingleOrDefault(x =] x.ID == 8);
dbContext.Employees.DeleteOnSubmit(employee);
dbContext.SubmitChanges();
}

https://cafeadobro.ro/

https://www.stagebox.uk/wp-includes/depo10-bonus10/

depo 25 bonus 25

https://parfumschristianblanc.com/

https://www.barplate.com/wp-includes/js/qris/

https://hotmusic507.org/

Enjoyed this video?
"No Thanks. Please Close This Box!"