Пример #1
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         db.Dispose();
     }
     base.Dispose(disposing);
 }
Пример #2
0
 public ActionResult Index2()
 {
     if (Session["UserName"] == null)
     {
         return(RedirectToAction("login", "home"));
     }
     else
     {
         northwindEntities2 db    = new northwindEntities2();
         List <Products>    model = db.Products.ToList();
         db.Dispose();
         return(View(model));
     }
 }
Пример #3
0
        // GET: Customers
        public ActionResult Index()
        {
            List <Customers> model = new List <Customers>();

            try
            {
                northwindEntities2 entities = new northwindEntities2();
                model = entities.Customers.ToList();
                entities.Dispose();
            }
            catch (Exception ex)
            {
                ViewBag.ErrorMessage = ex.GetType() + ": " + ex.Message;
            }

            return(View(model));
            //return View(db.Customers.ToList());
        }
Пример #4
0
        public ActionResult GetOrders(string id)
        {
            northwindEntities2 entities = new northwindEntities2();
            List <Orders>      orders   = (from o in entities.Orders
                                           where o.CustomerID == id
                                           select o).ToList();

            entities.Dispose();

            List <SimpleOrderData> result = new List <SimpleOrderData>();

            foreach (Orders order in orders)
            {
                SimpleOrderData data = new SimpleOrderData();
                data.CustomerId = order.CustomerID;
                data.OrderId    = order.OrderID;
                data.OrderDate  = order.OrderDate.ToString();
                result.Add(data);
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }