コード例 #1
0
 static void UpdateCustomer(string ID)
 {
     //var randomRabbitName = Console.ReadLine();
     using (var db = new CustomerDbContext())
     {
         var updateCustomer = db.Customers.Find(ID);
         updateCustomer.Country += "Bolivia";
         db.Customers.Update(updateCustomer);
         db.SaveChanges();
     }
 }
コード例 #2
0
 static void PrintCustomers()
 {
     using (var db = new CustomerDbContext())
     {
         customers = db.Customers.ToList();
     }
     foreach (var customer in customers)
     {
         Console.WriteLine($"{customer.CustomerID,-10}{customer.ContactName,-40}{customer.CompanyName,-40}{customer.City, -15}{customer.Country}");
     }
 }
コード例 #3
0
        static void AddCustomer()
        {
            Random rand        = new Random();
            var    newCustomer = new Customer()
            {
                CustomerID  = "RABSG",
                ContactName = "Ross Brown",
                CompanyName = "Sparta Global",
                City        = "Hemel Hempstead",
                Country     = "UK"
            };

            using (var db = new CustomerDbContext())
            {
                db.Customers.Add(newCustomer);
                db.SaveChanges();
            }
        }