Пример #1
0
        public IQueryable GetProducts()
        {
            var        db    = new WebForms.Models.ProductContext();
            IQueryable query = db.Products;

            return(query);
        }
Пример #2
0
 protected void RemoveProductButton_Click(object sender, EventArgs e)
 {
     using (var db = new WebForms.Models.ProductContext())
     {
         int productId = Convert.ToInt16(DropDownRemoveProduct.SelectedValue);
         var myItem    = (from c in db.Products where c.ProductID == productId select c).FirstOrDefault();
         if (myItem != null)
         {
             db.Products.Remove(myItem);
             db.SaveChanges();
             string pageUrl = Request.Url.AbsoluteUri.Substring(0, Request.Url.Query.Count());
             Response.Redirect(pageUrl + "?ProductAction=remove");
         }
         else
         {
             LabelRemoveStatus.Text = "Unable to locate product.";
         }
     }
 }