Пример #1
0
 private static void CreateNorthwindTwin()
 {
     using (var db = new NorthwindEntities())
     {
         db.Database.CreateIfNotExists();
         db.SaveChanges();
     }
 }
Пример #2
0
 private static void DeleteCustomerFromCustomerTable(string customerId)
 {
     using (var db = new NorthwindEntities())
     {
         Customer customer = GetCustomerByCustomerId(customerId, db);
         db.Customers.Remove(customer);
         db.SaveChanges();
     }
 }
Пример #3
0
        private static void ModifyCustomerInCustomerTable(string customerId,
                                                          string companyName,
                                                          string contactName,
                                                          string contactTitle,
                                                          string address,
                                                          string city,
                                                          string region,
                                                          string postalCode,
                                                          string country,
                                                          string phone,
                                                          string fax)
        {
            using (var db = new NorthwindEntities())
            {
                Customer customer = GetCustomerByCustomerId(customerId, db);
                customer.CustomerID = customerId;
                customer.CompanyName = companyName;
                customer.ContactName = contactName;
                customer.ContactTitle = contactTitle;
                customer.Address = address;
                customer.City = city;
                customer.Region = region;
                customer.PostalCode = postalCode;
                customer.Country = country;
                customer.Phone = phone;
                customer.Fax = fax;

                db.SaveChanges();
            }
        }
Пример #4
0
        private static void InsertNewCustomerInCustomerTable(string customerId,
                                                             string companyName,
                                                             string contactName,
                                                             string contactTitle,
                                                             string address,
                                                             string city,
                                                             string region,
                                                             string postalCode,
                                                             string country,
                                                             string phone,
                                                             string fax)
        {
            using (var db = new NorthwindEntities())
            {
                Customer newCustomer = new Customer();
                newCustomer.CustomerID = customerId;
                newCustomer.CompanyName = companyName;
                newCustomer.ContactName = contactName;
                newCustomer.ContactTitle = contactTitle;
                newCustomer.Address = address;
                newCustomer.City = city;
                newCustomer.Region = region;
                newCustomer.PostalCode = postalCode;
                newCustomer.Country = country;
                newCustomer.Phone = phone;
                newCustomer.Fax = fax;

                db.Customers.Add(newCustomer);
                db.SaveChanges();
            }
        }