protected void btnDelete_Click(object sender, EventArgs e) { using (SampleDataContext dbContext = new SampleDataContext()) { // Employees newEmployes = dbContext.Employees.SingleOrDefault(x => x.ID == 23); // dbContext.Employees.DeleteOnSubmit(newEmployes); var newEmployes = from emp in dbContext.Employees where emp.FirstName == "Robert" select emp; dbContext.Employees.DeleteAllOnSubmit(newEmployes); dbContext.SubmitChanges(); } GetData(); }
protected void btnUpdate_Click(object sender, EventArgs e) { using (SampleDataContext dbContext = new SampleDataContext()) { // Employees newEmployes = dbContext.Employees.SingleOrDefault(x => x.ID == 23); // newEmployes.Salary = 65000; var newEmployes = from emp in dbContext.Employees where emp.FirstName == "Robert" select emp; foreach (Employees data in newEmployes) { data.Salary = 65000; } dbContext.SubmitChanges(); } GetData(); }
protected void btnInsert_Click(object sender, EventArgs e) { using (SampleDataContext dbContext = new SampleDataContext()) { Employees newEmployes = new Employees() { FirstName = "Robert", LastName = "K", Gender = "Male", Salary = 55000, DepartmentId = 1 }; dbContext.Employees.InsertOnSubmit(newEmployes); dbContext.SubmitChanges(); } GetData(); }