public static void UpdateCategory(Product[] products, Category newCategory)
 {
     using (DbNorthwind db = new DbNorthwind())
     {
         foreach (Product prod in products)
         {
             prod.Category = newCategory;
             db.Update(prod);
         }
     }
 }
        public static void ReplaceByProduct(Product newProduct)
        {
            using (DbNorthwind db = new DbNorthwind())
            {
                var prod = from p in db.Product
                                where p.ProductID == newProduct.ProductID
                                select p;
                if (prod.Count() == 0)
                    newProduct.ProductID = Convert.ToInt32(db.InsertWithIdentity(newProduct));

                var q = (from o in db.Order
                        where o.ShippedDate == null
                        select o).ToList();
                foreach (Order order in q)
                {
                    OrderDetail orderDetail = (from od in db.OrderDetail
                                               where od.Order.OrderID == order.OrderID
                                               select od).First();
                    orderDetail.Product = newProduct;
                    db.Update(orderDetail);
                }
            }
        }