public ActionResult StuList()
        {
            //通过泛型集合定义一个学生集合,同时进行初始化操作,并返回该集合列表
            //List<T>
            List <StudentDemo> stuList = new List <StudentDemo>();
            StudentDemo        stu1    = new StudentDemo {
                Id = 1, Name = "张三", ClassName = "2018软件技术一班"
            };
            StudentDemo stu2 = new StudentDemo {
                Id = 2, Name = "李四", ClassName = "2018软件技术一班"
            };
            StudentDemo stu3 = new StudentDemo {
                Id = 3, Name = "王五", ClassName = "2018软件技术一班"
            };
            StudentDemo stu4 = new StudentDemo {
                Id = 4, Name = "申七", ClassName = "2018软件技术一班"
            };
            StudentDemo stu5 = new StudentDemo {
                Id = 5, Name = "秦六", ClassName = "2018软件技术一班"
            };

            stuList.Add(stu1);
            stuList.Add(stu2);
            stuList.Add(stu3);

            return(View());
        }
        public ActionResult Index()
        {
            ExampleGenriceList genriceList = new ExampleGenriceList();
            var stuList = genriceList.GetAll();
            //模糊查询
            IEnumerable <StudentDemo> list1 = stuList.Where(x => x.ClassName.Contains("软件"));
            //精确查询
            IEnumerable <StudentDemo> list2 = stuList.Where(k => k.Name == "王五");
            //获取符合条件的单条数据
            StudentDemo stu1 = stuList.Where(k => k.Name == "王五").FirstOrDefault();


            return(null);
        }
Example #3
0
        public ActionResult StuList()
        {
            //通过泛型集合名义一个学生集合,同时进行初始化操作,并返回该集合列表
            //List<T>
            List <StudentDemo> students = new List <StudentDemo>();
            StudentDemo        stu1     = new StudentDemo();

            stu1.Id        = 10;
            stu1.Name      = "门矢士";
            stu1.ClassName = "平成10周年班";
            StudentDemo stu2 = new StudentDemo();

            stu2.Id        = 20;
            stu2.Name      = "常磐庄吾";
            stu2.ClassName = "平成20周年班";
            students.Add(stu1);
            students.Add(stu2);
            return(View(students));
        }
        public List <StudentDemo> GetAll()
        {
            List <StudentDemo> students = new List <StudentDemo>();
            StudentDemo        stu1     = new StudentDemo();

            stu1.Id        = 10;
            stu1.Name      = "门矢士";
            stu1.ClassName = "平成10周年班";
            StudentDemo stu2 = new StudentDemo();

            stu2.Id        = 20;
            stu2.Name      = "常磐庄吾";
            stu2.ClassName = "平成20周年班";
            StudentDemo stu3 = new StudentDemo {
                Id = 30, Name = "zero1", ClassName = "令和"
            };

            students.Add(stu3);
            students.Add(stu1);
            students.Add(stu2);
            return(students);
        }
Example #5
0
        public List <StudentDemo> GetAll()
        {
            List <StudentDemo> stuList = new List <StudentDemo>();
            StudentDemo        stu1    = new StudentDemo {
                Id = 1, Name = "张三", ClassName = "2018软件技术一班"
            };
            StudentDemo stu2 = new StudentDemo {
                Id = 2, Name = "李四", ClassName = "2018软件技术一班"
            };
            StudentDemo stu3 = new StudentDemo {
                Id = 3, Name = "王五", ClassName = "2018软件技术一班"
            };
            StudentDemo stu4 = new StudentDemo {
                Id = 4, Name = "申七", ClassName = "2018软件技术一班"
            };
            StudentDemo stu5 = new StudentDemo {
                Id = 5, Name = "秦六", ClassName = "2018软件技术一班"
            };

            stuList.Add(stu1);
            stuList.Add(stu2);
            stuList.Add(stu3);
            return(stuList);
        }