/// <summary> /// 获取用户上传视频,过滤已添加到空间视频 /// </summary> /// <param name="userId"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> public MyVideoViewResult GetUserVideoViews(int userId, int pageIndex, int pageSize) { var result = new MyVideoViewResult() { MyVideoViews = new List <MyVideoView>(), TotalCount = 0 }; IQueryable <MyVideoView> queryable; queryable = (from myvideo in _videoRepository.GetEntityList(CondtionEqualCreateManageId(userId)) where myvideo.VideoState == 3 &&//TODO 刘强CheckState=1 !(from userroomchoose in this._userRoomChooseRepository.GetEntityList(CondtionEqualUserId(userId)) where userroomchoose.TypeId == 0 select new { userroomchoose.ModuleId }).Contains(new { ModuleId = (Int32)myvideo.Id }) select new MyVideoView { Id = myvideo.Id, Title = myvideo.Title, CommentCount = myvideo.CommentCount, PlayCount = myvideo.PlayCount, SmallPicturePath = myvideo.SmallPicturePath, VideoState = myvideo.VideoState, CreateTime = myvideo.CreateTime }).AsQueryable(); if (!queryable.Any()) { return(result); } result.TotalCount = queryable.Count(); result.PageCount = queryable.Count() % pageSize == 0 ? queryable.Count() / pageSize : queryable.Count() / pageSize + 1; result.MyVideoViews = queryable.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList(); return(result); }
public void GetUserVideoViews() { int UserId = 42; int albumId = 144; Stopwatch ww = new Stopwatch(); ww.Start(); var result = new MyVideoViewResult() { MyVideoViews = new List <MyVideoView>(), TotalCount = 0 }; //IQueryable<MyVideoView> queryable; //queryable = // (from myvideo in _videoRepository.GetEntityList(CondtionEqualState()) // where myvideo.CreateManageId == UserId && myvideo.VideoState == 3//TODO 刘强CheckState=1 // && !(from uss in this._userSpecialSonRepository.GetEntityList(CondtionEqualSpecialId(albumId)) // select new // { // uss.VideoId // }).Contains(new { VideoId = (Int32)myvideo.Id }) // select new MyVideoView // { // Id = myvideo.Id, // Title = myvideo.Title, // CommentCount = myvideo.CommentCount, // PlayCount = myvideo.PlayCount, // SmallPicturePath = myvideo.SmallPicturePath, // VideoState = myvideo.VideoState, // CreateTime = myvideo.CreateTime, // About = myvideo.About // }).AsQueryable(); #region new var queryable = (from myvideo in _videoRepository.GetEntityList(CondtionEqualState()).Where(o => o.CreateManageId == UserId && o.VideoState == 3) join uss in this._userSpecialSonRepository.GetEntityList() on myvideo.Id equals uss.VideoId into ussList from ut in ussList.DefaultIfEmpty() orderby myvideo.CreateTime select new { Id = myvideo.Id, Title = myvideo.Title, SmallPicturePath = myvideo.SmallPicturePath, SpecialId = ut == null ? 0 : ut.MySpecialId }); var list = queryable.GroupBy(o => o.Id).Where(o => o.FirstOrDefault(s => s.SpecialId == albumId) == null) .Select(o => new MyVideoView { Id = o.Key, Title = o.First().Title, SmallPicturePath = o.First().SmallPicturePath }); #endregion //if (!queryable.Any()) return result; result.TotalCount = list.Count(); result.PageCount = GetPageCountToDataCount(result.TotalCount); result.MyVideoViews = list.Skip(PageSize * (PageIndex - 1)).Take(PageSize).ToList(); ww.Stop(); long ttt = ww.ElapsedTicks; //return result; }