コード例 #1
0
 public static void Add(Employee employee)
 {
     using (var context = new SoftUniEntities())
     {
         context.Employees.Add(employee);
         context.SaveChanges();
     }
 }
コード例 #2
0
 public static void Modify(Employee employee)
 {
     using (var context = new SoftUniEntities())
     {
         context.Employees.Attach(employee);
         context.Entry(employee).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
コード例 #3
0
 public static void Delete(Employee employee)
 {
     using (var context = new SoftUniEntities())
     {
         context.Employees.Attach(employee);
         context.Employees.Remove(employee);
         context.SaveChanges();
     }
 }
コード例 #4
0
        public void Add()
        {
            var gandolf = new Employee()
            {
                FirstName = "Gandolf",
                LastName = "Thegray",
                JobTitle = "Network Administrator",
                DepartmentID = 11,
                HireDate = new DateTime(2001, 03, 27),
                Salary = 32500
            };

            EmployeeDao.Add(gandolf);
            this.employee = gandolf;

            Assert.IsNotNull(gandolf.EmployeeID);
        }