public PartialViewResult Index(string Uid, DateTime?createTime, int page = 1) { int count = 0; // list=client.GetYogaPicturePageList(page, 10, out count); list = client.GetYogaPicturePageList(0); var finq = (from l in list group l by new { PictureType = l.PictureType, Uid = l.Uid, iAudio = l.iAudio, CreateTime = l.CreateTime } into grouped orderby grouped.Key.CreateTime descending select new ViewYogaPicture { PictureType = grouped.Key.PictureType, Uid = grouped.Key.Uid, iAudio = grouped.Key.iAudio, CreateTime = grouped.Key.CreateTime }); if (!string.IsNullOrEmpty(Uid)) { ViewYogaUserDetail model = userDetclient.GetByRealName(Uid); if (model != null) { finq = finq.Where(x => x.Uid == model.UID); } else { ViewYogisModels models = modelclient.GetByRealName(Uid); if (models != null) { finq = finq.Where(x => x.Uid == models.UID); } } } if (createTime != null) { finq = finq.Where(x => x.CreateTime >= createTime.Value); } count = finq.Count(); var finqlist = finq.OrderBy(x => x.CreateTime).Skip((page - 1) * 10).Take(10).ToList(); PagedList <ViewYogaPicture> pagelist = new PagedList <ViewYogaPicture>(finqlist, page, 10, count); List <ViewYogaPictureGroup> listGroup = new List <ViewYogaPictureGroup>(); foreach (var item in finqlist) { ViewYogaPictureGroup model = new ViewYogaPictureGroup(); model.entity = item; using (YogisModelsServiceClient uclient = new YogisModelsServiceClient()) { ViewYogisModels mm = uclient.GetYogisModelsById(item.Uid); if (mm != null) { model.RealName = mm.RealName; if (string.IsNullOrEmpty(mm.RealName)) { ViewYogaUserDetail mmm = userDetclient.GetYogaUserDetailById(item.Uid); if (mmm != null) { model.RealName = mmm.RealName_cn; } } } else { ViewYogaUserDetail mmm = userDetclient.GetYogaUserDetailById(item.Uid); if (mmm != null) { model.RealName = mmm.RealName_cn; } if (mmm != null) { model.RealName = mmm.RealName_cn; } } } listGroup.Add(model); } ViewBag.listGroup = listGroup; return(PartialView("Index", pagelist)); }