예제 #1
0
        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();
        }
예제 #2
0
        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();
        }
예제 #3
0
        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();
        }