コード例 #1
0
        public ViewResult Index()
        {
            var model = new HomePageViewModel();
            //var employee = new Employee() { ID = 1, Name = "张三" };
            //return View(employee);

            SQLEmployeeData sqlData = new SQLEmployeeData(_context);

            model.Employees = sqlData.GetAll();


            return(View(model));
        }
コード例 #2
0
        [AllowAnonymous] //允许不登录访问
        public ViewResult Index()
        {
            //var employee = new Employee { ID = 1, Name = "语非" };
            //return View(employee);
            //var model = new HomePageViewModel();
            //using (var context = new HelloWorldDBContext())
            //{
            //    SQLEmployeeData sqlData = new SQLEmployeeData(context);
            //    model.Employees = sqlData.GetAll();
            //}
            var             model   = new HomePageViewModel();
            SQLEmployeeData sqlData = new SQLEmployeeData(_context);

            model.Employees = sqlData.GetAll();


            return(View(model));
        }