Ejemplo n.º 1
0
 private static void InsertCustomer(Customer customer)
 {
     using (var context = new DataAccess.AdventureWorksLTContext())
     {
         context.Set <Customer>().Add(customer);
         context.SaveChanges();
     }
 }
Ejemplo n.º 2
0
 //Question 3.
 //1) Write a method to create test data for Employees table (seeding data).
 private static void CreateEmployeeTestData(List <Employee> employees)
 {
     using (var context = new DataAccess.AdventureWorksLTContext())
     {
         foreach (var employee in employees)
         {
             context.Set <Employee>().Add(employee);
         }
         context.SaveChanges();
     }
 }
Ejemplo n.º 3
0
 //Create
 private static void InsertCustomers(List <Customer> customers)
 {
     using (var context = new DataAccess.AdventureWorksLTContext())
     {
         foreach (var customer in customers)
         {
             context.Set <Customer>().Add(customer);
         }
         context.SaveChanges();
     }
 }
Ejemplo n.º 4
0
 //Delete
 // DeleteCustomers??? Do we really need to delete many customers at the same time? What are the requirements for that?
 // Do we delete them by id range or what would be the parameters?
 private static void DeleteCustomerById(int id)
 {
     using (var context = new DataAccess.AdventureWorksLTContext())
     {
         var customer = context.Customer
                        //.Include(c => c.SalesOrderHeader)
                        //.Include(c => c.CustomerAddress)
                        .SingleOrDefault(c => c.CustomerId == id);
         context.Set <Customer>().Remove(customer);
         context.SaveChanges();
     }
 }