protected void btnUpdate_Click(object sender, EventArgs e) { using (ContactsDataContext dbContext = new ContactsDataContext()) { Employee employee = dbContext.Employees.SingleOrDefault (x => x.ID == 8); employee.Salary = 6500; dbContext.SubmitChanges(); } GetData(); }
protected void btnDelete_Click(object sender, EventArgs e) { using (ContactsDataContext dbContext = new ContactsDataContext()) { Employee employee = dbContext.Employees.SingleOrDefault (x => x.ID == 8); dbContext.Employees.DeleteOnSubmit(employee); dbContext.SubmitChanges(); } GetData(); }
protected void btnInsert_Click(object sender, EventArgs e) { using (ContactsDataContext dbContext = new ContactsDataContext()) { Employee newEmployee = new Employee { FirstName = "Time", LastName = "T", Gender = "Male", Salary = 5000, DepartmentId = 1 }; dbContext.Employees.InsertOnSubmit(newEmployee); dbContext.SubmitChanges(); } GetData(); }