コード例 #1
0
 public void CanAddEmployeeUsingAstonEngineerContext()
 {
     Employee employeeToAdd = new Employee
     {
         FirstName = "Alex",
         LastName = "Bigham",
         SSN = "111-22-3333",
         BirthDate = new DateTime(2000, 1, 1),
         HireDate = new DateTime(2005, 1, 1),
         TermDate = new DateTime(2010, 1, 1),
         DriverLicenseExpireDate = new DateTime(2020, 1, 1)
     };
     var context = new AstonEngineerContex();
     context.Employee.Add(employeeToAdd);
     context.SaveChanges();
 }
コード例 #2
0
        public void CanAddPersonUsingAstonEngineerContext()
        {
            //instantiate a new person class
            Person personToAdd = new Person
            {
                FirstName = "Margaret",
                MiddleName = "Elizabeth",
                LastName = "Bigham",
                BirthDate = new DateTime(1986, 1, 13),
                SSN = "123-45-6789"
            };

            //instatniate a new Context and add the Person to it.
            var context = new AstonEngineerContex();

            context.People.Add(personToAdd);
            context.SaveChanges();
        }