コード例 #1
0
        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));
        }
コード例 #2
0
 public CategoryRepository()
 {
     db = new NorthWindDB(ConfigurationManager.ConnectionStrings["NWContext"].ConnectionString);
 }
コード例 #3
0
        // GET: Home
        public ActionResult Index()
        {
            var Context = new NorthWindDB();

            return(View(Context.Categories.ToList()));
        }