Пример #1
0
 static void Delete(string customerID)
 {
     var db = new northwindEntities();
     using (db)
     {
         var customerToDelete = db.Customers.Find(customerID);
         db.Customers.Remove(customerToDelete);
         db.SaveChanges();
     }
 }
Пример #2
0
        static void Delete(string customerID)
        {
            var db = new northwindEntities();

            using (db)
            {
                var customerToDelete = db.Customers.Find(customerID);
                db.Customers.Remove(customerToDelete);
                db.SaveChanges();
            }
        }
Пример #3
0
 static void Edit(string customerID, string companyName, string city, string country)
 {
     var db = new northwindEntities();
     using (db)
     {
         var customerToEdt = db.Customers.Find(customerID);
         customerToEdt.CompanyName = companyName;
         customerToEdt.City = city;
         customerToEdt.Country = country;
         db.SaveChanges();
     }
 }
Пример #4
0
        static void Edit(string customerID, string companyName, string city, string country)
        {
            var db = new northwindEntities();

            using (db)
            {
                var customerToEdt = db.Customers.Find(customerID);
                customerToEdt.CompanyName = companyName;
                customerToEdt.City        = city;
                customerToEdt.Country     = country;
                db.SaveChanges();
            }
        }
Пример #5
0
        static void Add(string customerID, string companyName, string city, string country)
        {
            var db = new northwindEntities();
            using(db)
            {
                var customer = new Customer() {
                    CustomerID = customerID,
                    CompanyName = companyName,
                    City = city,
                    Country = country
                };

                db.Customers.Add(customer);
                db.SaveChanges();
            }
        }
Пример #6
0
        static void Add(string customerID, string companyName, string city, string country)
        {
            var db = new northwindEntities();

            using (db)
            {
                var customer = new Customer()
                {
                    CustomerID  = customerID,
                    CompanyName = companyName,
                    City        = city,
                    Country     = country
                };

                db.Customers.Add(customer);
                db.SaveChanges();
            }
        }
Пример #7
0
        static void FindSalesByDateRange(string region, DateTime startDate, DateTime endDate)
        {
            var db = new northwindEntities();

            using (db)
            {
                var sales = db.Orders
                            .Where(x => x.ShipRegion == region &&
                                   x.OrderDate > startDate &&
                                   x.OrderDate < endDate)
                            .Select(x => new
                {
                    ShipDate = x.ShippedDate,
                    Region   = x.ShipRegion
                });

                db.SaveChanges();
                foreach (var sale in sales)
                {
                    Console.WriteLine("Ship date " + sale.ShipDate + " Ship Region " + sale.Region);
                }
            }
        }
Пример #8
0
        static void FindSalesByDateRange(string region, DateTime startDate, DateTime endDate)
        {
            var db = new northwindEntities();
            using (db)
            {
                var sales = db.Orders
                    .Where(x => x.ShipRegion == region
                    && x.OrderDate > startDate
                    && x.OrderDate < endDate)
                    .Select(x => new
                    {
                        ShipDate = x.ShippedDate,
                        Region = x.ShipRegion
                    });

                db.SaveChanges();
                foreach (var sale in sales)
                {
                    Console.WriteLine("Ship date " + sale.ShipDate + " Ship Region " +  sale.Region);
                }

            }
        }