public ActionResult Show(int id = 0) { List <Category> Categories; var Context = new NorthWindDB(); if (id == 0) { Categories = Context.Categories.ToList(); } else { Categories = (from c in Context.Categories where c.CategoryID == id select c).ToList(); } return(View("Index", Categories)); }
public CategoryRepository() { db = new NorthWindDB(ConfigurationManager.ConnectionStrings["NWContext"].ConnectionString); }
// GET: Home public ActionResult Index() { var Context = new NorthWindDB(); return(View(Context.Categories.ToList())); }