Esempio n. 1
0
 protected void Delete_Click(object sender, EventArgs e)
 {
     NorthwindDataContext db = new NorthwindDataContext();
     Product product = db.Products.Single(p => p.ProductName.StartsWith("Scott's"));
     db.Products.DeleteOnSubmit(product);
     db.SubmitChanges();
     ShowProducts();
 }
Esempio n. 2
0
        protected void Update_Click(object sender, EventArgs e)
        {
            NorthwindDataContext db = new NorthwindDataContext();

            Product product = db.Products.First(p => p.ProductName.StartsWith("Scott's"));
            product.UnitPrice += 2.25m;
            db.SubmitChanges();
            ShowProducts();
        }
Esempio n. 3
0
        protected void Insert_Click(object sender, EventArgs e)
        {
            NorthwindDataContext db = new NorthwindDataContext();

            Product p1 = new Product { CategoryID = 1, ProductName = "Scott's Apple Juice", UnitPrice = 4.23m };
            db.Products.InsertOnSubmit(p1);
            db.SubmitChanges();
            ShowProducts();
        }
Esempio n. 4
0
        private void ShowProducts()
        {
            NorthwindDataContext db = new NorthwindDataContext();

            var products = from p in db.Products
                           where p.Category.CategoryName == "Beverages"
                           orderby p.ProductID descending
                           select new { p.ProductID, p.ProductName, p.Category.CategoryName, Price = p.UnitPrice };

            GridView1.DataSource = products;
            GridView1.DataBind();
        }