public ActionResult Index2() { northwindEntities1 db = new northwindEntities1(); List <Products> model = db.Products.ToList(); db.Dispose(); return(View(model)); }
protected override void Dispose(bool disposing) { if (disposing) { db.Dispose(); } base.Dispose(disposing); }
// GET: Products public ActionResult Index() { if (Session["UserName"] == null) // Tässä tarkastetaan onko käyttäjä kirjautunut sisään { return(RedirectToAction("login", "home")); } else { northwindEntities1 db = new northwindEntities1(); List <Products> model = db.Products.ToList(); db.Dispose(); return(View(model)); } }