public ActionResult List(Models.DormStudent.List vm)
 {
     return(Code.MvcHelper.Post(null, Url.Action("List", new
     {
         SearchText = vm.SearchText,
         SexId = vm.SexId,
         RoomId = vm.RoomId,
         BuildId = vm.BuildId,
         pageIndex = vm.Page.PageIndex,
         pageSize = vm.Page.PageSize
     })));
 }
        public ActionResult List()
        {
            var vm = new Models.DormStudent.List();

            using (var db = new XkSystem.Models.DbContext())
            {
                vm.BuildList = Areas.Basis.Controllers.BuildController.SelectList();
                vm.SexList   = Dict.Controllers.DictSexController.SelectList();

                var tb = db.Table <Dorm.Entity.tbDormStudent>();
                var dormStudentList = db.Table <Dorm.Entity.tbDormStudent>().ToList();

                if (!string.IsNullOrEmpty(vm.SearchText))
                {
                    tb = tb.Where(d => d.tbRoom.RoomName.Contains(vm.SearchText));
                }
                if (vm.BuildId > 0)
                {
                    tb          = tb.Where(d => d.tbRoom.tbBuild.Id == vm.BuildId);
                    vm.RoomList = Basis.Controllers.RoomController.SelectList(0, Convert.ToInt32(vm.BuildId));
                }
                else
                {
                    vm.RoomList = Areas.Basis.Controllers.RoomController.SelectList();
                }
                if (vm.SexId > 0)
                {
                    tb = tb.Where(d => d.tbStudent.tbSysUser.tbSex.Id == vm.SexId);
                }
                if (vm.RoomId > 0)
                {
                    tb = tb.Where(d => d.tbRoom.Id == vm.RoomId);
                }

                vm.DormStudentList = (from p in tb
                                      orderby p.No
                                      select new Dto.DormStudent.List()
                {
                    Id = p.Id,
                    RoomName = p.tbRoom.RoomName,
                    BuildName = p.tbRoom.tbBuild.BuildName,
                    YearName = p.tbDorm.tbYear.YearName,
                    Sex = p.tbStudent.tbSysUser.tbSex.SexName,
                    StudentCode = p.tbStudent.StudentCode,
                    StudentName = p.tbStudent.StudentName
                }).ToPageList(vm.Page);
            }

            return(View(vm));
        }